WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] [Plugin: Magic Fields] Page templates (2 posts)

  1. magaworks
    Member
    Posted 4 years ago #

    I am developing a blog with multiauthor and I am having problems because I want them to choose between just 2 templates and the page has to be created under their own main page.

    Explaining better thi sis the situation:

    Each author has his own main Page. Then they can create as many pages as they want, but always under their own main page. This I accomplished with Role Scopper that gives them only acces to their main page, so any page they create will be a subpage of that one. And then in their main page I can list all subpages.
    But I want them to select from 2 templates, but I have 5 page templates. I do not want them to see the others, so I was thinking about creating a magic field where they can select between just these 2 templates with a drop down, but I have no idea how to call the the right template for the page with magic fields because the template field is already a custom field for pages with their own values.

    Should I do this in another way? Like a special category of posts with a special template and list all posts by author under their main page?
    And can I hide this category from showing anywhere on the blog besides under their main page?

    Any ideas how to make these two things work together?

    http://wordpress.org/extend/plugins/magic-fields/

  2. magaworks
    Member
    Posted 4 years ago #

    I figured out how to do this.

    I created a single template page for authors to use.
    Then I created a new write panel for them using that specifc template.
    Then I created a new Custom field for them to choose the Style of the template, based on it's colors (templateColor).
    Finally in that single template page for authors I have a condition to check for custom field 'templateColor' and load the right template page.
    If they don't choose a template, then it will load one of them by default.
    Here is the code for the template. Hope this helps someone having the same issue. I haven't tried it yet but it seems logical that this works. When I implement this I will check here again updating whether it worked or not.

    <?php /*
    
    	Template Name: Criaturas Works Single Page
    
    */
    ?>
    <?php
    	$template_color = get_post_meta( $post_id, 'templateColor' );
    	// Page Light colors
    	if ( $template_color = 'light' )
    	{
    		include(TEMPLATEPATH . '/page-works_light.php');
    	}
    	// Page Dark colors
    	elseif ( $template_color = 'dark' )
    	{
    		include(TEMPLATEPATH . '/page-works_dark.php');
    	}
    	// No style selected
    	else
    	{
    		include(TEMPLATEPATH . '/page-works_dark.php');
    	}
    	?>

Topic Closed

This topic has been closed to new replies.

About this Topic