Menu on Interior Pages

edited November 2013 in Modules
So I created a block called menu.php and I have this code in there calling my database:

<? $this->load->library->database; $sql = "select * from fuel_page_variables, fuel_pages where fuel_pages.location like ('work%') and fuel_pages.published = 'yes' and fuel_page_variables.page_id = fuel_pages.id and fuel_page_variables.name = 'page_title' order by fuel_page_variables.value;"; $result = $this->db->query($sql); foreach($result->result() as $row){ ?> <li><a href="/<? print $row->location; ?>"> <? print $row->value; ?></a></li> <? } ?>

When I publish my file, the links from the database show, but I get two error messages...

---
Severity: Notice

Message: Undefined property: MY_Loader::$library

Filename: _blocks/menu.php

Line Number: 3

---
A PHP Error was encountered
Severity: Notice

Message: Trying to get property of non-object

Filename: _blocks/menu.php

Line Number: 3

---

I'm using Fuel version 0.9.3

Comments

  • edited 6:51PM
    Use $CI instead of $this. Also, shouldn't it be $CI->load->database();
  • edited November 2013
    Awsm! Changing $this to $CI worked. I also used $CI->load->database();

    Here's my updated mark-up for reference:

    <? $CI->load->database(); $sql = "select * from fuel_page_variables, fuel_pages where fuel_pages.location like ('work%') and fuel_pages.published = 'yes' and fuel_page_variables.page_id = fuel_pages.id and fuel_page_variables.name = 'page_title' order by fuel_page_variables.value;"; $result = $CI->db->query($sql); foreach($result->result() as $row){ ?> <li><a href="/<? print $row->location; ?>"> <? print $row->value; ?></a></li> <? } ?>

    THANK YOU.
  • edited 6:51PM
    Hello... I have another _block question. Still using 0.9.3.

    When I update _blocks from the admin the changes aren't reflected on the front-end. However, when I update them in my WYSWIG, upload and update within the CMS the blocks work, but they really need to be manageable via admin.

    Do I need to add a helper somewhere?
  • edited 6:51PM
    Have you tried clearing the Page Cache in FUEL under the Manage area after making the change? Uploading and saving under the Blocks module in the CMS should be the same as just editing the view field contents. It will first look for a block in the CMS, and then look for a static view file.
Sign In or Register to comment.