Get Pages by Tags

edited March 2016 in Share
Hi,

I recently start building a page with Fuel CMS. Now I am running into a problem. I created pages at site -> pages. Added some Tags after enabling the Tags Module and extending the backend view. For now everything is fine. Tags are also added to the page in the fuel_page_variables table.
Now my problem. I want to make a query for pages created that way having specific tags and display the recent pages with these tags.
Example:
page A) tags ( food, travel)
page B) tags ( clothing)
page C) tags ( food)

Now I want to query all pages containing tags "food". Maybe easy, but I am stuck there.

tanks,
Christian

Comments

  • edited 3:10AM
    The tags module is primarily used for your simple modules to take advantage. However, you can extend the fuel_pages_model and change the pages module to associate it with the tags module. This thread discussion explains how to do that:
    http://forum.getfuelcms.com/discussion/comment/6648#Comment_6648

    $tag = $CI->fuel->tags->find_by_tag('food'); foreach($tag->pages as $page) : print_r($page->values()); endforeach;
  • edited 3:10AM
    Hi,

    thanks for your reply and sorry for the late reply/thank. I think I took care of all the steps. But when I call the foreach loop I get the following Error Message:

    ======================
    A PHP Error was encountered
    Severity: Notice
    Message: Trying to get property of non-object
    Filename: core/MY_Model.php
    Line Number: 5778
    ======================
    In that file at that position I find this code:

    $position = $rel_ids_flipped[$row->id];

    A quick check shows that the array is present, but I get this error. But when I change the line to this:

    $position = $rel_ids_flipped[$row['id']];

    It works, but I don't know why. Since I don't want to change your code, do you have an idea? Maybe it's a bug.

    thanks in advance,
    Christian
  • edited March 2016
    Does your model have a proper record class defined in it as well (minus the "_model" suffix). For example, if you had a model called Food_model, it should have a record class associated with it below that model that's the record class. The Food_model class will look for a record class with the same name minus the "s" at the end. In this case, since there is no "s" at the end of the model name, you can specify what it should look for:
    public $record_class = 'Food_item'; // the name of the record class (if it can't be determined)
    If no record class is found, it will default to an array which is what you are seeing.
  • edited 3:10AM
    Hi Admin,
    I tried it, but it did not work out. Now I try it with a simple module. Maybe it was too advanced for a beginner like me. But anyway thanks for your support.
    thanks a lot,
    Christian

    PS: the confirmation for the registration somehow is broken. I receive the message that the email successfully has been confirmed, but I keep getting the information to confirm my email address.
  • edited 3:10AM
    When you say you keep getting information to confirm your email address, is it a notification in the forum in the lower left corner or an email? What does the message say?
  • edited 3:10AM
    Hi, the message is in the lower left and sais:
    "You need to confirm your email address. Click here to resend the confirmation email."

    I let the system send me the mail about three times so far, but no change.
Sign In or Register to comment.