hello, I thought this would be straightforward - but it isn't!
I have a clonable template - art-and-poetry-projects.php. Within this template is a repeatable region for uploading images to create a lightbox.
Each art-and-poetry-projects.php page is shown on a listing page. A page view may or may not be required.
My objective is to create a shortcode so that the client can inject a link to launch a lightbox gallery wherever they wish. So this may be from the page in list view or it may be from the page in page view - if the page requires a detail page of its own.
The problem is that the page ID is not available to the shortcode in list view ... I don't know how to get hold of it. Here is the shortcode:
Heeeelp - anyone?
I have a clonable template - art-and-poetry-projects.php. Within this template is a repeatable region for uploading images to create a lightbox.
Each art-and-poetry-projects.php page is shown on a listing page. A page view may or may not be required.
My objective is to create a shortcode so that the client can inject a link to launch a lightbox gallery wherever they wish. So this may be from the page in list view or it may be from the page in page view - if the page requires a detail page of its own.
The problem is that the page ID is not available to the shortcode in list view ... I don't know how to get hold of it. Here is the shortcode:
- Code: Select all
$FUNCS->register_shortcode( 'lightbox', 'lightbox_handler' );
function lightbox_handler( $params, $content=null ){
global $FUNCS, $CTX;
extract( $FUNCS->get_named_vars(array(
'linktext' => '',
'linkstyle' => ''
), $params) );
$pageid = $CTX->get('k_page_id');
$html =<<<EOS
<cms:pages masterpage='art-and-poetry-projects.php' show_future_entries='1' id='$pageid' limit='1'>
<cms:show_repeatable 'lightbox_photos' >
<cms:if show_lightbox_photo eq 'yes' >
<a class="lightbox-link<cms:if k_count='1'> lightbox-link$linkstyle</cms:if>" href="<cms:show lightbox_photo />" <cms:if k_total_records gt '1'>data-lightbox-gallery="gallery<cms:show k_page_id/>"</cms:if> <cms:if "<cms:not_empty lightbox_photo_title />">title="<cms:show lightbox_photo_title/>"</cms:if>><cms:if k_count='1'>$linktext</cms:if></a>
</cms:if>
</cms:show_repeatable>
</cms:pages>
EOS;
return $FUNCS->embed( $html, $is_code=1 );
}
}
Heeeelp - anyone?