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/05 20:48]
Timbow [A System for Different Components on Different Pages]
components-depending-on-the_page [2014/02/07 10:48]
datiswous [A System for Different Components on Different Pages]
Line 21: Line 21:
  
 The following text needs to be in a functions.php file in your theme folder: The following text needs to be in a functions.php file in your theme folder:
-<​file><?​php+<​file ​php><?​php
 if (!function_exists('​component_exists'​)) { if (!function_exists('​component_exists'​)) {
     function component_exists($id) {     function component_exists($id) {
Line 48: Line 48:
  
 Make a component which will be the default component and call it say //​default//​. Make components for specific pages and name them to include the page slug of the page into which they are to be inserted, so name them say //​content-about//​ and //​content-contact//​. Then call the component in your page template as follows: Make a component which will be the default component and call it say //​default//​. Make components for specific pages and name them to include the page slug of the page into which they are to be inserted, so name them say //​content-about//​ and //​content-contact//​. Then call the component in your page template as follows:
-<​code>​+<​code ​php>
 <?​php ​ if (component_exists('​content-'​.get_page_slug(false))) <?​php ​ if (component_exists('​content-'​.get_page_slug(false)))
    {get_component('​content-'​.get_page_slug(false));​}    {get_component('​content-'​.get_page_slug(false));​}
components-depending-on-the_page.txt ยท Last modified: 2017/02/28 00:56 by Timbow