Using CMS Pages w/ Module Data too?

edited June 2011 in Modules
So I have a bunch of pages created through the CMS.
I also have a few modules to input data through the CMS.

I would like some of these pages to display body copy entered through the CMS, along with data that has been entered through the modules.

Just as an example, we'll use a page called Partners, which will display some body copy along with information about each partner.
This page lives at 'about-us/partners'.

So I enter the body copy through the CMS, and that works fine.
It's when I try to bring in the module data that I run into trouble.

I created a view file that lives at 'applications/views/about-us/partners.php'
In it, I put:
<?php $partners = fuel_model('partners', array('find' => 'all', 'precedence desc')); ?>
<?php foreach($partners as $partner) : ?>
// do stuff
<?php endforeach; ?>


However, because the page exists in the CMS, I never seem to make it to 'about-us/partners.php' view file.

Ideally I would like to use the fuel_model() function, along with my standard fuel variables, like:
<?php echo fuel_var('body', ''); ?>
Which would be inputted through the CMS.

What am I doing wrong?


Also, when I created the module, a file called 'partners_model.php' was created.
I assume this is the file that the fuel_model() function is hitting.
How do I tell fuel_model with method that I want to use?
IE- How does it know what to return?


Thanks.

Comments

  • edited 7:51PM
    So it sounds like you are wanting to merge in module information into your page controlled by the CMS correct? If so, you will need to use the Dwoo templating syntax OR you could import that view file and it should translate most of PHP code of your static view file into templating syntax for you into the 'body' variable in the CMS. An alternative could be to create a block file (either static or controlled in the CMS), and put all that partner specific code in that. Then in the body of the page in the CMS you could use {fuel_block('my_partner_block')} with 'my_partner_block' being the name of the block. This keeps a lot of the templating syntax out of your body of your page.

    With regards to the fuel_model(), there isn't a way to use custom methods on the model (instead we recommend using the select, where, limit, etc parameters with fuel_model if possible). To do that though, you could use the following in your static view file or block:
    $CI->load->model('partners_model'); $data = $CI->partners_model->my_custom_method();
    http://www.getfuelcms.com/user_guide/parsing
    http://www.getfuelcms.com/user_guide/helpers/fuel_helper

    Hope that helps.
  • edited 7:51PM
    Thanks for the quick answer!
    But it brings up a few more questions...


    "So it sounds like you are wanting to merge in module information into your page controlled by the CMS correct?"

    That is exactly what I am aiming to do.

    All of the solutions you mentioned involve placing some php/logic into the CMS though, correct?
    Ideally I would like to avoid that, as I will not be the only one making changes through the CMS, and I would hate for something to be removed by accident.

    Is it at all possible to have the module data display without putting any code in the CMS?


    Thanks.
  • edited 7:51PM
    Sure. You could put logic in the layout, and then select that layout for the page.

    The block is another alternative as mentioned above, but it does require one line in the body of {fuel_block('my_partner_block')}
Sign In or Register to comment.