Not allowed to create a same variable name for different scope in admin panel

edited August 2017 in Bug Reports
Hi Admin,

I have globally defined certain variables but I would like to alter them at the page level, which works great with the variable file, but I am not able to do the same from the site variable section from the admin panel(database level).

I am trying to create page_title variable again from the admin panel. One without the scope which will be a default entry while the other will be scope driven for specific page. The variable is page_title and should be affecting the URL about-us/who-we-are.

Please correct me if I am wrong : If we are working for the page on about-us/who-we-are URL then on the admin panel
scope will be about-us/who-we-are similar to $pages['about-us/who-we-are'] in the about-us.php variable file.

Comments

  • edited 7:05PM
    So you aren't creating pages in the CMS to contain those page specific variables but instead are using the Site variables with a scope? Is the page_title variable being overridden by another value? Site variables (even with a scope) have a lower precedence then page variables specified in the _variables files or in the CMS.
  • edited 7:05PM
    So here is the thing that I am trying to do. I am trying to shift the _variable file dependent pages to the database. I am trying to put the current structure below:

    I used the opt-in controller method to get my routes working and passed all the details and info from the variable file to the route.

    I created the layout file as per my requirements

    <?php $this->load->view('_blocks/custom_header')?>

    <?php $this->load->view('_blocks/menu/top_menu.php', array('active_menu' => $page_active_top_menu))?>

    <?php echo fuel_var('section_1'); ?>


    <?php echo fuel_var('breadcrumbs'); ?>
    <?php echo fuel_var('page_title_header'); ?>



    <?php echo fuel_var('section_2_1'); ?>


    ">
    <?php echo fuel_var('section_2_2'); ?>


    <?php echo fuel_var('section_2_3'); ?>



    <?php echo fuel_var('section_3'); ?>

    <?php $this->load->view('_blocks/custom_footer')?>
    If you take a look at the layout file, this file is built to be used in different routes.

    I have a route about-us/who-we-are and about-us/brand using the same layout file.

    My _varaible/about-us.php file looks like below:

    $pages = array();

    // generic global page variables used for all pages
    $who_we_are = array();
    $who_we_are['layout'] = 'layout_sub_menu_1_2_1';
    //$who_we_are['page_title'] = fuel_nav(array('render_type' => 'page_title', 'delimiter' => ' : ', 'order' => 'desc', 'home_link' => 'Home'));
    $who_we_are['page_title'] = 'Who We are : About ';
    $who_we_are['meta_keywords'] = '';
    $who_we_are['meta_description'] = '';
    //we will use the js and css declared in global.php
    /*$who_we_are['js'] = array();
    $who_we_are['css'] = array();*/
    $who_we_are['body_class'] = uri_segment(1).' '.uri_segment(2);



    $who_we_are['page_active_top_menu'] = 'about-us';
    $who_we_are['page_active_sub_menu_class'] = 'aboutustopbg';
    $who_we_are['background_banner_url'] = img_path('about_us/About-Us_1920x615-px.jpg') ;
    $who_we_are['background_banner_mob_url'] = img_path('about_us/mobile/AboutUs_banner_web.jpg');
    $who_we_are['page_active_sub_menu'] = 'who-we-are';
    $who_we_are['page_banner_text_content'] = 'Content Title
    sub heading content';

    $sub_about_menu_data = array(
    'active_menu' => $who_we_are['page_active_sub_menu'],
    'sub_menu_container_class' => $who_we_are['page_active_sub_menu_class'],
    'banner_text_content' => $who_we_are['page_banner_text_content'],
    'background_banner_url' => $who_we_are['background_banner_url'],
    'background_banner_mob_url' => $who_we_are['background_banner_mob_url']
    );

    $who_we_are['section_1'] = fuel_block('menu/sub_about_menu', $sub_about_menu_data);

    $who_we_are['breadcrumbs'] = '
    About Us
    Who We Are
    ';

    $who_we_are['page_title_header'] = '
    Who We Are

    ';

    $who_we_are['section_2_1'] = 'Big content section';

    $who_we_are['section_2_2_class'] = 'leadershipinfo';

    $who_we_are['section_2_2'] = 'Our Leadership

    Some content


    More content



    Click 1
    Click 2
    ';

    $who_we_are['section_2_3'] = '
    More click
    More click 2
    ';

    $who_we_are['section_3'] = fuel_block('news_watch_tweet_section');

    $pages['about-us/who-we-are'] = $who_we_are;
    I also had to create the view file for the route, which can be kept blank as well, but I have kept a line of code for understanding and also some comments for each of the views.
    View at the location views/about-us/who-we-are.php look like below:

    <?= fuel_set_var('layout', 'layout_sub_menu_1_2_1') ?>
    I tried to create the page with the given layout from the back-end but I didn't got the options to add the variable values like we get while selecting the main layout (automatically all variables are displayed in admin panel for admin to add entry into them for specific page)

    So, I created a page and now creating page specific variable via site variable section.
    After defining the variable once without the scope(global variables applicable throughout the site), the variables like page_title, layout, meta_keywords or any of the variable created once is not allowed to create again. PFA the screenshots https://ibb.co/hr1245 and https://ibb.co/g3Vej5

    I am not sure whether I am heading the right way for making _variable file driven pages to be updated from database.
  • edited 7:05PM
    The site variables is mostly intended for global variables with the scope being used limitedly. If you have page specific variables, I'd recommend setting them up as a page in the CMS. You can then use the controller if you would still like and pull in the variables created in the Pages module for your page.
  • If you have page specific variables, I'd recommend setting them up as a page in the CMS.
    - When I try to setup a page in the admin page and select my custom layout (code shared above in my previous code), I am not getting the variables associated to the layout in the admin panel. I tried to debug the code for layout change event but didn't got anything substantial.

    You can then use the controller if you would still like and pull in the variables created in the Pages module for your page
    - Are you referring that while import, if the variables are defined at the controller level then they would be pulled while creating the page in the admin panel! or your just informing that the variables created as per first point on this comment can be used in the controller as well!

    Sorry, but this my first time with Fuel, I may sound naive! Thanks
  • edited 7:05PM
    When you say "I am not getting the variables associated to the layout in the admin panel.", are you saying when you click save for the specified page, the layout values you input aren't saving? Or are you saying that you want to import the variables from the _variables file into a page in the CMS (under the pages module) and that is not working?

    If the latter, for that to work, you need to first specify a layout that has field names that match the variables you are wanting to import.
  • Yes, the case is the latter one.
    Where can I specify the layout with field names for the variable import to function properly? Any links for reference ?

    I already have layout file under _layout folder with the below code

    <?php $this->load->view('_blocks/custom_header')?>

    <?php $this->load->view('_blocks/menu/top_menu.php', array('active_menu' => $page_active_top_menu))?>

    <?php echo fuel_var('section_1'); ?>


    <?php echo fuel_var('breadcrumbs'); ?>
    <?php echo fuel_var('page_title_header'); ?>



    <?php echo fuel_var('section_2_1'); ?>


    ">
    <?php echo fuel_var('section_2_2'); ?>


    <?php echo fuel_var('section_2_3'); ?>



    <?php echo fuel_var('section_3'); ?>

    <?php $this->load->view('_blocks/custom_footer')?>
  • edited 7:05PM
    Here it talks about creating layouts:
    http://docs.getfuelcms.com/general/layouts
Sign In or Register to comment.