Hi all

In an app that I am currently developing I wish to give the
administrator the ability to customise the home page of the app by
being able to include various other things into the home page (For
example, the admin may wish to show a welcome message which uses the
pages controller, and they may wish to show a calendar using the
calendars controller and an unlimited number of other views).

What I am currently doing is on the homepage view I do a loop through
the homepages table and call the homepages.ctp element and sends it
the relevant data for the view that needs to be displayed. The
homepage element then calls the relevant element for whatever
controller the admin has chosen, this controller may be part of a
plugin.

The homepages.ctp element looks as follows:
<?php
if ($item['MenuLink']['plugin_id'] == 0)
{
        $View =& ClassRegistry::getObject('view');
        echo $View->element('homepages/' . $item['MenuLink']['controller'],
array('item' => $item));
}
else
{
        $View =& ClassRegistry::getObject('view');
        echo $View->element('homepages/' . $item['MenuLink']['controller'],
array('item' => $item, 'plugin' => $item['MenuLink']['Plugin']
['directory']));
}
?>

As an example the homepages/pages.ctp element looks as follows:
<?php $pageToShow = $this->requestAction('/pages/index/' . $item
['Homepage']['options']); ?>
<?php if (isset($pageToShow)) : ?>
        <div>
                <div id="dataInfo">
                        Created: <span class="timeago" title="<?php echo 
$pageToShow['Page']
['created']; ?>"><?php echo $date->prettyDate($pageToShow['Page']
['created']); ?></span><br />
                        Modified: <span class="timeago" title="<?php echo 
$pageToShow
['Page']['modified']; ?>"><?php echo $date->prettyDate($pageToShow
['Page']['modified']); ?></span><br />
                        Tags: <?php echo $pageToShow['Page']['tags']; ?>
                </div>

                <h1 id="nice_name"><?php echo $pageToShow['Page']['title']; 
?></h1>
                <div id="content" style="margin-top:10px; text-align:left;">
                        <?php
                        echo $pageToShow['Page']['text'];
                        ?>
                </div>
        </div>
<?php else : ?>
No page
<?php endif; ?>

It is working well. However, I realise that requestAction is quite
intensive as it acts like another server request, is there some other
method that I can use that will achieve the same outcome but use less
server resources?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to