0
Welcome Guest! Login
0 items Join Now

Problem adding Module Position to 404 Error Page

  • Problem adding Module Position to 404 Error Page

    Posted 9 years 7 months ago
    • Hello,

      This seems more of a gantry issue then a template issue so I hope its ok to post here.

      I am using the latest Anacron template with the latest grantry release. I am trying to add a module position inside the error.php file to better match the main site.

      Currently the error.php has 3 module positions that work as they should but I need to add 2 more positions.

      For example the module position for the header looks like this:
      <?php /** Begin Header **/ if ($gantry->countModules('header')) : ?>
      <div id="rt-header" class="<?php if ($gantry->get('header-overlay')!='') : ?><?php echo 'rt-overlay-'.$gantry->get('header-overlay'); ?><?php endif; ?>">
      	<div class="rt-container">
      		<?php echo $gantry->displayModules('header','standard','standard'); ?>
      		<div class="clear"></div>
      	</div>
      </div>
      <?php /** End Header **/ endif; ?>

      I try to add this code:
      <?php /** Begin Header Utility **/ if ($gantry->countModules('headerutility')) : ?>
      <div id="rt-header-utility">
      	<div class="rt-container">
      		<?php echo $gantry->displayModules('headerutility','standard','standard'); ?>
      		<div class="clear"></div>
      	</div>
      </div>
      <?php /** End Header Utility **/ endif; ?>

      With the code I try to add the module position doesn't show. Instead it returns a value of the following when I view the output code in Chrome Web Developer Tools:
      <div id="rt-header-utility">
      	<div class="rt-container">
      		<div class="rt-grid-12 rt-alpha rt-omega">
                  <jdoc:include type="modules" name="headerutility-a" style="standard" />
              </div>
      	<div class="clear"></div>
          </div>
      </div>

      Any idea whats going on here?

      Is there a better way to add module positions?

      The above custom code works just fine in the index.php

      Thanks
    • Damir's Avatar
    • Damir
    • Preeminent Rocketeer
    • Posts: 22450
    • Thanks: 2679
    • Web Developer

    Re: Problem adding Module Position to 404 Error Page

    Posted 9 years 7 months ago
  • Re: Problem adding Module Position to 404 Error Page

    Posted 9 years 7 months ago
    • Hello Damir,

      Yes it is delared.

      The code that is not working on the error.php page is actually a copy and past from the index.php.

      When I started building the website I added several new positions all of which work on any given page except for the error.php page.

      I assumed that since the default module positions on the error.php page were declared in the same way as in the index.php, if I added my custom postions to the error.php they would work but for some reason they don't.

      Currently (by default) the error.php includes the header-surround w/"header" position, showcase-surround w/"showcase" position, and footer-surround w/"copyright" position. These positions work as they should.

      Now if those module positions can be shown, why can't my custom positions. Is there another file that needs to be modified for this to work?

      In my first post I posted my website URL. Please take a look at it. Then try to force a 404 page by adding /blah or something to the URL. You will see the difference in the scroll header. I am trying to get the header on the 404 error page to match the main site. In other words I need to add 2 new module positions to the error.php.

      Thanks,
      Tracey
  • Re: Problem adding Module Position to 404 Error Page

    Posted 9 years 7 months ago
    • Hi again,

      Just an update, after doing some digging it seems that the file "libraries/gantry/core/renderers/gantrymodulesrenderer.class.php" is responsible for adding the <jdoc:include type="modules" name="headerutility-a" style="standard" /> I am seeing in my output code.(line 77)

      I do not have enough understanding of php to know why its adding the above code to the error page but maybe it will help you guys nail it down.

      Thanks,
      Tracey
  • Re: Problem adding Module Position to 404 Error Page

    Posted 9 years 7 months ago
    • I was able to solve this using some custom code but would still like some input to understand why the above method did not work.

      For anyone else interested in adding module positions this is what i did.

      I changed this:
      <?php /** Begin Header Utility **/ if ($gantry->countModules('headerutility')) : ?>
      <div id="rt-header-utility">
      	<div class="rt-container">
      		<?php echo $gantry->displayModules('headerutility','standard','standard'); ?>
      		<div class="clear"></div>
      	</div>
      </div>
      <?php /** End Header Utility **/ endif; ?>

      To this:
      <?php /** Begin Header Utility **/ ?>
      <div id="rt-header-utility">
      	<div class="rt-container">
      		<div class="rt-grid-12 rt-alpha rt-omega">
      			<?php
      			foreach (JModuleHelper::getModules('headerutility-a') as $module)
      			print(JModuleHelper::renderModule($module, array('style'=>'standard')));
      			?>
      		</div>
      		<div class="clear"></div>
      	</div>
      </div>
      <?php /** End Header Utility **/ ?>
    • The following users have thanked you: YellowWebMonkey

Time to create page: 0.057 seconds