getTitle returns title in wrong language?

0 views
Skip to first unread message

Niko Viitala

unread,
Dec 14, 2009, 12:28:45 PM12/14/09
to pkcontextcms
Hi,

I am developing a site in multiple languages and for some reason
getTitle() returns always Finnish titles no matter what culture is
set. However, it returns current page's title right.

$page = pkContextCMSTools::getCurrentPage();
$childs = $page->getParent()->getNode()->getChildren();
foreach($childs as $child) {
$child->getTitle() // All except current page prints in wrong language
}

I have tried to solve the problem by myself with no success... It gets
the title from slotCache (if I remember right), but I haven't figured
out where the title is set to the slotCache array to correct the
problem...


Thanks,
Niko

Tom Boutell

unread,
Dec 14, 2009, 12:36:32 PM12/14/09
to pkcont...@googlegroups.com
Hello Niko,

Fetch the children with $page->getChildren() which is culture-aware.

You can do it even faster with getChildrenInfo() which uses optimized
PDO calls and returns an array of associative arrays for each child,
with a 'title' key. That's usually best unless you truly need the full
page object.
> --
>
> 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

Niko Viitala

unread,
Dec 14, 2009, 1:17:02 PM12/14/09
to pkcontextcms
Thanks for your answer.

I would, but I need the parent's children. If i use it without getNode
() like $page->getParent()->getChildren() it works, but for some
reason after the components the normal slots doesn't show after that
and it doesn't output any kind of error. $page->getChildren() doesn't
cause that. $page->getParent()->getChildrenInfo() works wonderful, but
after that I need also every childrens children and it outputs an
array.

/ Niko
> > For more options, visit this group athttp://groups.google.com/group/pkcontextcms?hl=en.

Tom Boutell

unread,
Dec 14, 2009, 1:23:34 PM12/14/09
to pkcont...@googlegroups.com
Not sure what's happening with getParent()->getChildren(), it
shouldn't be possible for that to interfere with the slots of the
current page. There are no static class variables that could be doing
that.

I wonder if you fetched the page in the first place with a method that
returns only the title slot for efficiency? Note the difference
between retrieveBySlugWithTitles/retrieveByIdWithTitles and
retrieveBySlugWithSlots/retrieveByIdWithSlots. But it does sound like
you're working with the current CMS page inside a template somewhere.
Hmm.

If you want a tree, not just children, then use getTreeInfo(). This
returns a handy nested array. See the extensive comments before that
method in the code for details.

Also see the new nav component classes that are built on top of these
info methods, documentation for which is expected in the next day or
two.
> For more options, visit this group at http://groups.google.com/group/pkcontextcms?hl=en.

Niko Viitala

unread,
Dec 14, 2009, 2:04:40 PM12/14/09
to pkcontextcms
I am not sure what you mean. I have made own nav component to
pkContextCMSComponents which gets the page with
"pkContextCMSTools::getCurrentPage()" and after that I try to get the
page's parent's children with those commands.

I had no problems before when the menu was in layout.php but I changed
it's place to template and I had to add the getNode() part to get the
context showing and then I faced the language problem.

Maybe I should just update to the newest version so I could get the
getTreeInfo function and built in menus. :)

- Niko

Tom Boutell

unread,
Dec 14, 2009, 2:06:37 PM12/14/09
to pkcont...@googlegroups.com
Oh, you are using old code! Yes, run don't walk to svn and start using
the trunk, please don't suffer with ancient tarballs. (:
> For more options, visit this group at http://groups.google.com/group/pkcontextcms?hl=en.

Tom Boutell

unread,
Dec 14, 2009, 2:07:01 PM12/14/09
to pkcont...@googlegroups.com
(The trunk requires Symfony 1.3 or 1.4, which is a GOOD thing. But if
you absolutely insist on using 1.2, you can use the 1.2 branch in svn
and still be much better off than you are now)
> For more options, visit this group at http://groups.google.com/group/pkcontextcms?hl=en.
Reply all
Reply to author
Forward
0 new messages