How can I get the title slot for a particular page?

3 views
Skip to first unread message

Spike B

unread,
Jan 13, 2010, 5:09:45 PM1/13/10
to pkcontextcms
Hi again,

I'm trying to grab the title slot in my layout.php to display in a
<h1> at the top of each page. I see that there is a title slot for
each page in the database, but when I do a var_dump
(sfContext::getInstance()->getResponse()->getSlots()) from layout.php
I get:

array
'body_class' => string 'pk-default' (length=10)
'pk-slot-content-body-1' => string '

Edit this slot to change What We Do information.

' (length=60)
'pk-slot-controls-body-1' => string ' <li class="pk-controls-item
edit">
<a id="pk-slot-edit-body-1" class="pk-btn icon pk-edit" title="Edit"
href="#" onclick="; return false;">edit</a> <script type="text/
javascript">
$(document).ready(function(){
var editBtn = $('#pk-slot-edit-body-1');
var editSlot = $('#pk-slot-body-1');
editBtn.click(function(event){
$(this).parent().addClass('editing-now');
$(editSlot).children('.pk-slot-content').children('.pk-slot-content-
container').hide(); // Hide content
$(editSlot).children('.pk-sl'... (length=674)

It appears that the title slot is somehow unset? I tried grepping
through the code base and didn't find anything which might lead to the
answer.

Also, I don't just want to use the title from the sfWebResponse
object, because that is potentially different than the page title
itself.

Thanks!

Tom Boutell

unread,
Jan 13, 2010, 5:17:46 PM1/13/10
to pkcont...@googlegroups.com
CMS slots and Symfony slots are completely separate animals. See the
Symfony docs for more on Symfony slots. We do use Symfony slots for
certain implementation purposes and you're seeing that.

To grab the title, call getTitle on the page object.

$page = pkContextCMSTools::getCurrentPage();
if ($page)
{
echo ($page->getTitle());
}

It's important to check whether there is a current page if your layout
is also used by pages that are not in CMS land.

> --
> You received this message because you are subscribed to the Google Groups "pkcontextcms" group.
> To post to this group, send email to pkcont...@googlegroups.com.
> To unsubscribe from this group, send email to pkcontextcms...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/pkcontextcms?hl=en.
>
>
>
>

--
Tom Boutell
P'unk Avenue
215 755 1330
punkave.com
window.punkave.com

Reply all
Reply to author
Forward
0 new messages