It looks like you're new here. If you want to get involved, click one of these buttons!
<?php $this->load->view('_blocks/header')?>
<?php echo fuel_var('body', ''); ?>
<?php $this->load->view('_blocks/footer')?>
<?php
fuel_set_var('page_title', 'Title');
fuel_set_var('meta_description', 'This is a description.');
fuel_set_var('layout', 'home');
?>
$config['layouts']['home'] = array(
'fields' => array(
'Banner' => array('type' => 'fieldset', 'label' => 'Body', 'class' => 'tab'),
'heading' => array('label' => lang('layout_field_heading')),
'tagline' => array('label' => lang('layout_field_tagline')),
'body' => array('label' => lang('layout_field_body'), 'type' => 'textarea', 'description' => lang('layout_field_body_description')),
)
);
<div class="heading">
<h1><?php echo fuel_var('heading'); ?></h1>
<h2><?php echo fuel_var('tagline'); ?></h2>
</div>
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: wildcard_location
Filename: models/Fuel_pages_model.php
Line Number: 233
Backtrace:
File: /home/public_html/fuel/modules/fuel/models/Fuel_pages_model.php
Line: 233
Function: _error_handler
File: /home/public_html/fuel/modules/fuel/libraries/Fuel_pages.php
Line: 650
Function: find_by_location
File: /home/public_html/fuel/modules/fuel/libraries/Fuel_pages.php
Line: 558
Function: assign_location
File: /home/public_html/fuel/modules/fuel/libraries/Fuel_pages.php
Line: 525
Function: initialize
File: /home/public_html/fuel/modules/fuel/libraries/Fuel_pages.php
Line: 65
Function: __construct
File: /home/public_html/fuel/modules/fuel/controllers/Page_router.php
Line: 70
Function: create
File: /home/public_html/index.php
Line: 364
Function: require_once
Comments
https://github.com/daylightstudio/FUEL-CMS/commit/89409cf666662bc1aa7d6b04369b050c040b1d7e
if (empty($data) OR ($data['location'] != $location AND (!empty($wildcard_location) AND $data['location'] != $wildcard_location.'/:any')))
that the full toolbar displays at the top, but still having an issue with the Home page not loading. Why is it missing my home.php view? Like I mentioned, if I leave Fuel_pages_model.php as it was before, the page loads with an error and no inline editing capability.And it is editable in the CMS, as seen here: https://i.imgur.com/9GPUJxn.png
Looking at the steps in my original post, have I done something wrong or missed a step? The heading and tagline fields display on my Home page using <?php echo fuel_var('heading'); ?>, but I still get the "Undefined variable: wildcard_location" error. If I update Fuel_pages_model to if (empty($data) OR ($data['location'] != $location AND (!empty($wildcard_location) AND $data['location'] != $wildcard_location.'/:any'))) then only my header and footer blocks load.
https://github.com/daylightstudio/FUEL-CMS/blob/develop/fuel/modules/fuel/models/Fuel_pages_model.php#L233
$data = $this->find_one_array($where, 'location desc');
Add the following to echo out the query to test at line 231 in the Fuel_pages_model file:
$this->debug_query(); echo '<pre>'; print_r($data); echo '</pre>'; exit();
This is the query and associated return data that finds the data in the fuel_pages table. What does it print out?
If you just want to store the page data in the CMS and incorporate that in your view files, you can call $CI->fuel->pagevars->retrieve('my_location') and it will return an array of just the data associated with the location. You can then use a controller to display the page (controllers take precedence over pages created in the CMS). If you don't want any pages rendered through the CMS, you can change MY_fuel.php $config['fuel_mode'] = 'views';
http://docs.getfuelcms.com/libraries/fuel_pagevars
http://docs.getfuelcms.com/general/pages-variables
That sounds like what I want to do, but I'm not sure how to achieve it. I already created a home page in the CMS, and created application/views/home.php (which is where the HTML is and where I'd like specific variables that can be edited through the CMS Pages module), application/views/_layouts/home.php (which is currently just a copy of main.php, not sure if correct), and $config['layouts']['home'] in application/config/MY_fuel_layouts.php which has my custom fields for heading and tagline. So now I need to create application/controllers/home.php?
This is my attempt, still unsure how to pass custom variables:
<?php class Home extends CI_Controller { function __construct() { parent::__construct(); } function home() { $vars = array(); $vars = array('heading' => 'I want this editable in the CMS', 'tagline' => 'Same with this'); $page_init = array('location' => 'home'); $this->load->module_library(FUEL_FOLDER, 'fuel_page', $page_init); $this->fuel_page->add_variables($vars); $this->fuel_page->render('home', $vars); } } ?>
Where does $CI->fuel->pagevars->retrieve('home') need to go? Do I need to create application/views/_variables/home.php as well? Can I delete any of the files/functions mentioned in my original post? Thank you for your time.
I think you want $this->fuel->pages->render(....):
http://docs.getfuelcms.com/general/pages-variables#controller
I have $this->fuel_page->render('home', $vars); Should it be something else?
Note that it's $this->fuel->pages->render()... That is an older syntax (but may still work). Regarding where to put $CI->fuel->pagevars->retrieve('home'), I would merge it with your $vars variable since that's all it is is an array of variables to pass to your page.
I now have:
<?php class Home extends CI_Controller { function __construct() { parent::__construct(); } function home() { $vars = array(); $vars = $CI->fuel->pagevars->retrieve('home'); $this->fuel->pages->render('home', $vars); } } ?>
Does that look correct? I still have <?php echo fuel_var('heading'); ?> in my home view for example, but the text from the CMS isn't loading.
If you print_r on $vars, is the variable in their?
When I add <?php print_r($vars); ?> to application/views/home.php, this happens:
Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 57525451 bytes) in /home/public_html/fuel/modules/fuel/libraries/Fuel_pages.php on line 1355<br /> A PHP Error was encountered<br /> Severity: Error<br /> Message: Allowed memory size of 134217728 bytes exhausted (tried to allocate 57525451 bytes)<br /> Filename: libraries/Fuel_pages.php<br /> Line Number: 1355<br /> Backtrace:
OK. That's because their is probably an infinite loop to referencing the $CI object and print_r can't handle it. Try print_r(array_keys($vars)) and see if the the name of the variable is in that array.
I just got back from vacation, ready to try and solve this again! Haha.
Array ( [0] => layout [1] => page_title [2] => meta_keywords [3] => meta_description [4] => js [5] => css [6] => body_class [7] => CI )
The array does not contain heading or tagline.
Whenever I click on home in the Pages module, I get the message, "There is an updated view file located at /public_html/fuel/application/views/home.php. Would you like to upload it into the body of your page (if available)?" I've been clicking No, because there is no body field. Should I hit yes?
The location is set to home, layout is set to home, and layout variables for Heading and Tagline are filled in. What else can I try?
Hit no for the import.
If you go to the "home" page under Pages in the CMS, does it having your heading and tagline fields?
Yes, it does.
So you see them saved in the database under fuel_page_variables with the home's page_id in the page_id column?
Both entries are there with page_id = 1 (which is home).
Has the
fuel_mode
in fuel/application/config/MY_fuel.php been set toauto
(e.g. $config['fuel_mode'] = 'auto';)Also, in your controller you have:
Try replacing
$CI
with$this
When I set fuel_mode to auto (instead of views), only the header and footer blocks load. Updated the controller to use $this instead of $CI, but it didn't make a difference. Array is still the same as it was before: Array ( [0] => layout [1] => page_title [2] => meta_keywords [3] => meta_description [4] => js [5] => css [6] => body_class [7] => CI ).
You'll definitely want it set to "auto" instead of "views" if you are wanting to pull data from the CMS. If you create another page in the CMS does it pull in more data than home?