Using CMS Pages w/ Module Data too?
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
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.
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.
The block is another alternative as mentioned above, but it does require one line in the body of {fuel_block('my_partner_block')}