Wednesday, February 27, 2013

Re: Viewing 2 or more elements in the same view in Cakephp

The elements are children to current view or a building blocks of your view.

There's no problem with displaying multiple element in one view.

Try it with simple elements:
# elem.ctp:
<div>elem test</div>

#elem2.ctp:
<div>elem 2</div>

# view.ctp:
<h1>My elments</h1>
<?php echo $this->element('elem'); ?>
<?php echo $this->element('elem2'); ?>
<?php echo $this->element('elem'); ?>
<?php echo $this->element('elem2'); ?>

But, if you're using some elements with JavaScript maybe they are not initialized properly. Do you check HTML output or debug the page in Firebug or Chrome Dev Tools?

Also check your names, you could have some typo. Enable debug mode and check errors.


On Wednesday, February 27, 2013 8:53:44 AM UTC+1, Victor Musvibe wrote:
I am using Google API for displaying charts on my app. I am trying to view more than two elements on the same view page (index.ctp). Meaning i am trying to have more than 2 Charts on the same view page. The index page is only showing the policies_accessible2012.ctp element.

Here is how i am calling the elements in my index.ctp

    <body>
    <table width="100%" border="0" cellspacing="2" cellpadding="2">
    <tr>
    <td><div><?php echo $this->element('SurveyResults/2011/policies_accessible2011'); ?></div></td>
    <td></td>
    <td><div><?php echo $this->element('SurveyResults/2012/policies_accessible2012'); ?></div></td>
    </tr>
    </table>
    </body>

I do understand that if i have the following code, this will result in SurveyResults/2012/policies_accessible2012 rendered as the parent view to the current view

    <?php echo $this->element('SurveyResults/2011/policies_accessible2011'); ?>
    <?php echo $this->element('SurveyResults/2012/policies_accessible2012'); ?>

I am just wondering if they is a way to show the 2 or more elements on the same view. Thank you in advance

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments: