User Tools

Site Tools


components-depending-on-the_page

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision Both sides next revision
components-depending-on-the_page [2014/02/07 10:48]
datiswous [A System for Different Components on Different Pages]
components-depending-on-the_page [2017/02/28 00:47]
Timbow
Line 5: Line 5:
  
 Don't forget to replace **PAGE** with your **page'​s slug** and **COMPNAME** with the **component'​s name**. Don't forget to replace **PAGE** with your **page'​s slug** and **COMPNAME** with the **component'​s name**.
 +
 +=====Several Pages Each with Different Components=====
 +Say you have three pages with the slugs //index//, //about//, //contact// and sidebars as components named //peter//, //paul// and //mary// you would edit your template to replace **<?php get_component(sidebar);​ ?>** with
 +<​code>​
 +<?php if (return_page_slug()=='​index'​) {get_component('​peter'​);​}
 + ​elseif (return_page_slug()=='​about'​) {get_component('​paul'​);​}
 +else {get_component('​mary'​);​} ?> </​code>​
 +which in English reads
 +  *If** the page slug is //index// insert the component //peter//,
 +  **otherwise if** the page slug is //about// insert the component //paul//
 +  and **otherwise** just insert the component //mary//.
 +
  
 ===== Components Depending On The Parent Page ===== ===== Components Depending On The Parent Page =====
components-depending-on-the_page.txt ยท Last modified: 2017/02/28 00:56 by Timbow