Integrate managed CMS content with a custom PHP page

edited October 2011 in Installation
I am trying to get an about page installed on my site, with the
About being managed with FuelCMS, but above the article there is a custom jQuery carousel. How do I integrate CMS-managed content into a custom php controller/view? Is this a "Page" that would be managed in the CMS called About, or is this something else? I can't seem to determine if the "Page" concept integrates with custom code, or if it is, by definition, the entire content of the web page. If it can be integrated, how?

Again, thanks so much for the help with this.

Comments

  • edited 11:12AM
    There are a couple ways you can do this:

    Option #1
    Create a page in the admin, and then create a static block that has all the logic to create your jQuery carousel (e.g. grabs data from the model and creates the image code for the carousel). After creating your block, you can insert into your page using the fuel_block function like so using the Dwoo templating code:
    {fuel_block('carousel')}If you are wanting the ability to edit the carousel code from the admin, then you can import the block in the Blocks module, but you will need to convert any custom php code to Dwoo templating code. FUEL will try and do most if not all of that conversion for you but it depends on how complicated your PHP logic is in the block.

    Option #2
    You can create a layout that contains the logic for your carousel and select that layout when creating the page.
  • edited 11:12AM
    I've been following your second option, since it makes more sense to me to include Page variables in a custom view file than to add custom view code into the Page.

    I'm struggling, though, because I feel like I'm making _layout templates for one-off uses, and I probably won't use them for more than one page. Not to mention that I have to include the header and footer on each _layout template. This doesn't seem like the right way to do it, and I can't create a hierarchical folder structure to manage my views.

    So I'm wondering if there is a way to reference Page variables from a standard view without just querying the fuel_page_variables table.

    Does this make sense, or am I actually doing the right thing with the _layout templates? Thanks for your help!
  • edited 11:12AM
    It's tough to say without seeing the different pages you have but I'll tell you what we typically do in situations where the layouts are a bit different across pages.

    Normally I like to try and keep the number of layouts to a minimum and build in as much logic that makes sense into the main layout to keep the client options to a minimum and avoid confusion. You can also use _variables files to set certain variables in the layout as well (for example, all pages in the about section get a certain set of blocks or a top image...etc). Some times we'll create a layout that sort of "inherits" from another by doing something like the following:
    //in new layout file, views/_layouts/my_new_layout.php $vars['top_image'] = 'about_top_image.jpg'; $vars['blocks'] = array('recent_news', ''); $this->load->view('_layouts/main.php', $vars);
    With regards to getting page variables into your standard view, you could try the following:
    $CI->load->module_library(FUEL_FOLDER, 'fuel_page', array('location' => 'about/contact', 'render_mode' => 'cms')); $variables = $CI->fuel_page->variables();
    This page may also be helpful if you haven't seen it yet:
    http://www.getfuelcms.com/user_guide/general/creating-pages
Sign In or Register to comment.