YooRecipe End Of Life

Hi,

YooRecipe comes to an end as I do not have time to maintain it anymore. Subscriptions are now closed starting from Sep 27. SUPPORT REMAINS ACTIVE FOR ACTIVE SUBSCRIBERS.

All the best!

Sylvain.

How to add your own layouts?

Learn how to add new display possibilities to YooRecipe thanks to layouts.

Sometimes, you want to customize the display of a component to make it more suitable to your needs. Most of the time, if you modify code, you lose your modifications the next time you update. That is now old story.

Indeed, YooRecipe has been developed accordingly to Joomla Framework requirements.

Recipes blog Layouts

Since version 5.0.0, YooRecipe uses Joomla layouts for blog pages and recipe page display.

These layouts are defined in /components/com_yoorecipe/layouts folder. YooRecipe automatically detects available layouts in Component Options, as shown below.

In other words, adding a new display layout consists in adding a file under /components/com_yoorecipe/layouts/recipes or /components/com_yoorecipe/layouts/recipe folder.

Create your own layout

This is really simple. Let's assume you copied a layout to mylayout.php. Half of the work is already done. You just have to edit your mylayout.php file and modify the code as you want.

YooRecipe uses PHP Objects and we assume you have at least basic PHP programming skills.

A recipe object can be represented like this:

 

stdClass Object
(
    [id] => 487
    [access] => 1
    [title] => Zesty Sundried Tomato Broccoli Capellini
    [alias] => zesty-sundried-tomato-broccoli-capellini
    [description] => 	How to make Zesty Sundried Tomato Broccoli Capellini
    [created_by] => 61
    [preparation] => PREPARATION TEXT
    [serving_type_id] => 1
    [nb_persons] => 4
    [difficulty] => 2
    [cost] => 2
    [sugar] => 0
    [carbs] => 0
    [fat] => 0
    [saturated_fat] => 0
    [cholesterol] => 0
    [proteins] => 0
    [fibers] => 0
    [salt] => 0
    [kcal] => 337
    [kjoule] => 0
    [diet] => BOOLEAN
    [veggie] => BOOLEAN
    [gluten_free] => BOOLEAN
    [lactose_free] => BOOLEAN
    [creation_date] => 2015-05-20 11:46:44
    [publish_up] => 0000-00-00 00:00:00
    [publish_down] => 0000-00-00 00:00:00
    [preparation_time] => 15
    [cook_time] => 25
    [wait_time] => 10
    [picture] => images/com_yoorecipe/61/broccoli.jpg
    [video] => 
    [published] => 1
    [cuisine] => LATIN
    [validated] => 1
    [featured] => 1
    [nb_views] => 3
    [note] => 
    [language] => en-GB
    [language_title] => English (UK)
    [servings_type] => Person(s)
    [metakey] => 
    [metadata] => 
    [use_slider] => 1
    [slug] => 487:zesty-sundried-tomato-broccoli-capellini
    [catslug] => 79:plats
    [favourite] => 0
    [author_name] => Super Utilisateur
    [author_email] => email address
    [access_level] => Accès Public
    [ingredients] => Array of stdClass objects
    [categories] => Array of stdClass objects
    [seasons] => Array()
    [ratings] => Array()
    [tags] => JHelperTags Object
    [similar_recipes] => Array of recipes objects
)

Echoing a recipe title can be done this way:

echo $recipe->title

Our advice is to look at already existing layouts, so that you create your own layout quickly!

  • Thursday, 28 May 2015

Leave a comment

Please login to leave a comment.