by
potato » Sun Jul 27, 2014 11:20 pm
Yes, sorry, I am aiming to allow a client to inject modal windows into any richtext editable area. I will create a cloneable template say, modals.php, with probably 3 editable areas 1. modal launch button text 2. modal content heading and 2. modal content. The client will add a new modals.php cloned page and fill in the data. They will take the cloned page name they have assigned and enter the following within the richtext editable area of the other page:
[modal name="xyz"]
I have no problem getting hold of the data from a cloned page within the shortcode (I'm using a cloned template called list-items.php just for now - testing it all out on my local machine).
I want to allow the client to inject more than one modal window per richtext editable area - so I need to assign a unique identifier to various parts of the modal markup (from Bootstrap) - and this is where k_page_id comes in.
I hope this all makes sense.
this is the full shortcode:
- Code: Select all
<?php
$FUNCS->register_shortcode( 'modal', 'modal_handler' );
function modal_handler( $params, $content=null ){
global $FUNCS, $CTX;
extract( $FUNCS->get_named_vars(array(
'page' => $CTX->get( 'k_page_id' ),
'name' => '#'
), $params) );
$html = "<button class=\"btn btn-primary btn-lg\" data-toggle=\"modal\" data-target=\"#myModal\">
Launch demo modal {$page}
</button>
<div class=\"modal fade\" id=\"myModal\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"myModalLabel\" aria-hidden=\"true\">
<div class=\"modal-dialog\">
<div class=\"modal-content\">
<div class=\"modal-header\">
<button type=\"button\" class=\"close\" data-dismiss=\"modal\"><span aria-hidden=\"true\">×</span><span class=\"sr-only\">Close</span></button>
<h4 class=\"modal-title\" id=\"myModalLabel\">Modal title</h4>
</div>
<div class=\"modal-body\">
<cms:get_custom_field 'list_item' masterpage='list-items.php' page='{$name}' />
</div>
<div class=\"modal-footer\">
<button type=\"button\" class=\"btn btn-default\" data-dismiss=\"modal\">Close</button>
</div>
</div>
</div>
</div>";
return $FUNCS->embed( $html, $is_code=1 );
}
It is a bit experimental at the moment ...