Jump to content



Recommended Posts


As my first project I chose to create a recipe page.  Not really inventing the wheel, I know, but It's a fun project and there are a few learning points.

Now I have set up the database and I can create recipes and they look ok so that's kinda sorted. 

What I want to do next is categorizing.  The "recipe" template has a page reference field called category where each recipe can get categorized by more than one category and I want to be able to sort the recipes by category.  I've been fiddling about with find() but not really gotten it to work properly, can someone please give me a little push, an idea to get me on the right track.

Thank you,


Link to comment
Share on other sites

Depending on what you are trying to achieve, one approach is to have a page ref field in the category template to ref back to the recipes, then use the ConnectPageFields module to keep them in sync. That then gives you lots of options for viewing and updating. 

Link to comment
Share on other sites

If you create a page reference field named 'recipe_category' and want to find everything in the category 'soup', you could do something like this:

$categoryPage = $pages->get("name=soups");
$soups = $pages->find("template=recipes, recipe_category=$categoryPage");

Alternatively, if you could use a select options field (easier to set up, but less flexible and harder to change anything, so usually page reference fields are better in the long run):

$soups = $pages->find("template=recipes, recipe_category.title=soups");


Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...