I am using the 1.1 version.
For the code you list below if you change it to the following you should be good to go. I have not tested this in 1.0 though.
Overall the modification in my snippet and the code below could use a little optimization to reduce line count and unnecessary operations, but I think my snippet make it easier for some to modify the
1.1 code.
function display()
{
if (!func_num_args())
{
$this->redirect('/');
}
$path = func_get_args();
if (!count($path))
{
$this->redirect('/');
}
/* BEGIN MODIFICATION 1 */
$title = ucfirst($path[count($path)-1]);
$title_pieces = explode("_", $title);
foreach($title_pieces as $key => $value) {
$title_pieces[$key] = ucfirst($value);
}
$title = implode(" ", $title_pieces);
/* END MODIFICATION 1 */
$this->set('page', $path[0]);
$this->set('subpage', empty($path[1])? null: $path[1]);
/* BEGIN MODIFCATION 2 */
$this->set('title', ucfirst($path[count($path)-1]));
/* END MODIFICATION 2 */
$this->render(join('/', $path));
}
On 5/30/06, Langdon Stevenson <
[EMAIL PROTECTED]> wrote:
>
> Hi John
>
> Can you tell me which version of Cake this applies to? The display
> function in pages_controller.php of Cake version 1.0.0.2378 looks like
> the following, so I am unclear about how to apply the snippet.
>
>
> function display()
> {
> if (!func_num_args())
> {
> $this->redirect('/');
> }
> $path = func_get_args();
> if (!count($path))
> {
> $this->redirect('/');
> }
> $this->set('page', $path[0]);
> $this->set('subpage', empty($path[1])? null: $path[1]);
> $this->set('title', ucfirst($path[count($path)-1]));
> $this->render(join('/', $path));
> }
>
>
> Regards,
> Langdon
>
> John Zimmerman [gmail] wrote:
> > If anyone is interested I added a snippet to cakeforge that is a
> > modifcation to the pages_controller.php that displays the thtml files
> > located in /app/views/pages.
> >
> > Basically it will make the titles look like....
> >
> > 'Page Title'
> >
> > instead of....
> >
> > 'Page_title'
> >
> > Here is the link...
> >
> > http://cakeforge.org/snippet/detail.php?type=snippet&id=68
> > <
http://cakeforge.org/snippet/detail.php?type=snippet&id=68>
>
>
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---
- Re: Prettier Static Pages Snippet Langdon Stevenson
- Re: Prettier Static Pages Snippet Larry E. Masters aka PhpNut
- Re: Prettier Static Pages Snippet John Zimmerman [gmail]
- Re: Prettier Static Pages Snippet Langdon Stevenson
- Re: Prettier Static Pages Snippet John Zimmerman [gmail]
