Note the upgraded forum! If you are experiencing issues logging in, you may need to reset your password which should send an email. If the email doesn't arrive, be sure to check your spam folder just in case.

Displaying Archives and Categories

edited February 2011 in Modules
Hi, MoOose here again...

I am now trying to pull the Archives and Categories and have taken and edited the following code from /fuel/blog/modules/blog/views/theme/default/_blocks/

Again this works fine in the Home and Blog pages but as soon as I go to my other pages then they break

I get the following Error message on these pages
Severity: Notice
Message: Undefined variable: CI
Filename: _blocks/footer.php

I do have $CI =& get_instance(); declared in global.php...
your assistance is greatly appreciated by this noOob =}

Archives

<?php $archives_by_month = $CI->fuel_blog->get_post_archives(); ?>
<?php if (!empty($archives_by_month)) : ?> <?php endif; ?>




Categories

<?php $posts_to_categories = $CI->fuel_blog->get_posts_to_categories(); ?>
<?php if (!empty($posts_to_categories)) : ?> <?php endif; ?>

Comments

  • edited February 2011
    I'm assuming that this code lives in the footer block right? If pages are created in the FUEL admin instead of static view files, then the CI variable is not sent to the page (for security reasons). Although their is a $CI variable declared in the global variables file, it is really only there for the variables file and not passed to the page (so you can use it to grab segment values and load additional helpers etc). For view files, that $CI variables is actually passed around Line 341 of fuel/modules/fuel/libraries/Fuel_page.php. To pass "globally", you'll need to add it to the $vars array like so:
    $vars['CI'] =& get_instance();
    Or, you could also declare $CI directly in the footer block.
    $CI =& get_instance();
  • edited 10:41AM
    Great!!! Working now, also had to change the $this to $CI on the following line because it gave following error - Call to member function url() on a non-object

    fuel_blog->url($month); ?>"><?php echo $month_str; ?>


    Completed code below for reference

    Archives

    <?php
    $CI =& get_instance();
    $archives_by_month = $CI->fuel_blog->get_post_archives();
    if (!empty($archives_by_month)) : ?> <?php endif; ?>

    Categories

    <?php $posts_to_categories = $CI->fuel_blog->get_posts_to_categories(); ?>
    <?php if (!empty($posts_to_categories)) : ?> <?php endif; ?>

    Thanks again for all your help,
    muchas gracias mi amigo =}
  • edited 10:41AM
    No problem... glad it helped.
Sign In or Register to comment.