tertiary level page variables

edited December 2014 in Modules
Hi all,

Say I have a FUEL site with the three following pages:

division1/productsheet
division2/productsheet
division3/productsheet

Here different product divisions use the same product sheet. In the "productsheet" view, I can pull in variables from the global.php file, from a division file (say division1.php), but I can't seem to find a way to have a _variables file specific to "productsheet"?

I dont' want all my variables to be loaded in the global.php file as I have many that are specific to the productsheet. I don't want/need to create any "divisionx" files (I might have 10 or 15). Is this possible to have a variable file that targets pages 2 or 3 levels deep?

Comments

  • edited December 2014
    In situations like this, I would recommend one of the following methods:

    1. In your global.php file you can use the $pages variable with a regular expression key. Perhaps something like:
    $pages[':any/productsheet$'] = array('var1' => 'var1_value');

    2. In your global.php file, you include a variables file based on certain URI segment values though.
    if (uri_segment(2) == 'productsheet') { include(APPPATH.'views/_variables/productsheet'); }
  • edited 8:09PM
    Awesome! Both of these work great! Just what I needed. Thanks!

    BTW, typo in your 1st suggestion: should be a bracket after "productsheet" --> $pages[':any/productsheet$'] = array('var1' => 'var1_value');
  • edited 8:09PM
    Thanks... fixed the typo.
Sign In or Register to comment.