- This topic has 2 replies, 2 voices, and was last updated 6 years, 5 months ago by
giec.
-
AuthorPosts
-
-
August 16, 2015 at 8:16 am #4215
giecMemberSteve,
thanks again for your help with this one, https://piklist.com/support/topic/adding-a-repeatable-div/. I played around with that, made some changes and now attempted it again.
So here is what I have this http://antonioborrillo.co.uk/andys/index.php/home/new-test-page-2/. And here is the code
New page: http://antonioborrillo.co.uk/andys/index.php/home/new-test-page-2/
my-field.php:<?php /* Title: My Metabox Description: My cool new metabox Post Type: page */ // Let's create a text box field piklist('field', array( 'type' => 'select' ,'field' => 'my_divs' ,'label' => __('Select a Div') ,'add_more' => true ,'choices' => array( 'div_one' => 'Div One' ) )); // Let's create a text box field /*piklist('field', array( 'type' => 'textarea' ,'field' => 'my_divs' ,'label' => __('Add your code') ,'add_more' => true ) */ ?>My template file, test_templ.php
<?php /* Template Name: New Test page*/ ?> <?php get_header(); ?> <?php $my_divs = get_post_meta($post->ID, 'my_divs'); // Get the field data foreach ($my_divs as $my_div => $name) // loop through each add_more { get_template_part('custom-div', $name); // display the template } ?> <?php get_footer(); ?>and finally the custom-div-div_one.php
<div class="infoBox one"> <h2></h2> <p></p> </div>and finally the custom-div-div_one.php
<div class="infoBox one"> <h2></h2> <p></p> </div>OK, so here is a screenshot of what I have in the dashboard:
http://s30.postimg.org/gtj1d3cvl/plugin.png
SO the infoBox one div (well three of them in fact) have been successfully injected in the page, here is a screenshot to prove that).
http://s24.postimg.org/gne5t93dx/plugin_results.png
So, all good but there are a few things:
-for this new page I used a different template, is there anyway I can get the metabox with my divs to appear only when I select a specific template in the dashboard? When I add a new page in the template drop down box in the dashboard I get a choice of templates to select and among those my custom template. Can I get the metabox to appear only when my custom template is selected? does the plugin support this type of behaviour?
-the divs added have a heading and a p tag inside, same as see in custom-div-div_one.php above: is there anyway the customer can edit those and enter text in the h and p tags – at the moment they are empty and I don’t have anyway to add stuff to them -
August 17, 2015 at 10:02 am #4219
SteveKeymaster@giec– Glad you’re making progress on this.
1) Piklist “sort of” supports only showing the fields in the admin if the page template is selected. Use the template parameter.
2) To show the data, you are going to have to use this doc, and replace custom-div-div_one.phpLet me know if that makes sense.
-
September 9, 2015 at 9:33 am #4301
giecMemberThanks Steve. Sorry for the very slow reply, but I’ve been away with no internet for a while.
I’ll have a look at this and try to cook up something, then post back
thanks for your help!
-
-
AuthorPosts
- You must be logged in to reply to this topic.