Problems, need help? Have a tip or advice? Post it here.
5 posts Page 1 of 1
I wonder if this is another one for shortcodes or if I'm missing a simpler solution ...

I have an editable region of type 'file' for the client to upload a PDF document - in the globals.php template. They will then want to link to this in more than one location in the website. I can get the link as follows:

Code: Select all
<a href="<cms:get_custom_field 'brochure_name' masterpage='globals.php' />" target="_blank" >DOWNLOAD BROCHURE ABC</a>


Should I now create the above bit of code as a shortcode so the user keys in something like
Code: Select all
[brochure_ABC_download/]


Now I've asked the question, I'm convinced it must be the way to do it!?
I'm not sure if you ended up solving this. I was planning on posting a reply a few days ago, but I forgot. :| Shortcodes should work fine.
Code: Select all
$FUNCS->register_shortcode( 'brochure_abc_download', 'brochure_abc_download_handler' );
function brochure_abc_download_handler( $params, $content=null ){
global $FUNCS;
extract( $FUNCS->get_named_vars(array(
'text' => 'DOWNLOAD BROCHURE ABC'
), $params) );
$html = "<a href=\"<cms:get_custom_field 'brochure_name' masterpage='globals.php' />\" target=\"_blank\">{$text}</a>";
return $FUNCS->embed( $html, $is_code=1 );
}

Usage:
Code: Select all
[brochure_abc_download]
OR
[brochure_abc_download text="Alternate Link Text"]

It's also good to hear you got that popover script setup and working. :)
Thanks for another slice of help cheesypoof ... I realised that I'd set things up incorrectly on a set of cloned pages. Each page had a common link to a downloadable PDF document and I had set up an editable region of type:file within the clonable template. So every cloned page has the document uploader in the admin panel. I should have set the file up as a global/custom field which is then fetched (i.e. cms:get_custom_field) within the page template (outside any editable region). Additionally the shortcode for the client to use on other pages within the site is a nice feature (although they could achieve the same thing with the wysiwyg I suppose).

Have you been using shortcodes much on sites you are building?
While a link can always be inserted through the editor, the advantage of using a shortcode in this case is that the link is not hardcoded. For example, uploading a new brochure with a different file name and trying to update all of the editor-inserted download links in your different editable regions could waste a lot of time unnecessarily. Nevertheless I'm sure you already understood all of this. :D

The site I'm currently working on makes use of shortcodes on the store product pages. In cases where there are different attributes for a product, I found shortcodes to be very well suited. Below is an example of how the attributes for a wheel are generated:
Code: Select all
[attribute name="Size"]
[option price="200.00"]18 x 8.5[/option]
[option price="200.00"]18 x 9.5[/option]
[option price="215.00"]19 x 8.5[/option]
[option price="225.00"]19 x 9.5[/option]
[option price="225.00"]19 x 10[/option]
[option price="300.00"]20 x 9[/option]
[option price="300.00"]20 x 10[/option]
[/attribute]

[attribute name="Finish"]
[option]Super Silver[/option]
[option]Hyper Black[/option]
[option]Gunmetal[/option]
[option]Matte Black[/option]
[/attribute]

Each 'attribute' shortcode outputs a 'label' tag and 'select' tag with the accompanying 'option' tags inside. This can also set a product price attribute for each 'option' tag so that when selected, JavaScript modifies the displayed price.
re links, mmmm to be honest I hadn't necessarily considered that, no ... the transition from making brochure sites to a CMS driven site is requiring a more 'three dimensional' way of thinking about everything ... far more interesting.

re your use of shortcodes :shock:
(perhaps when your site goes live I can have a look at it - it would be very educational I think!)
5 posts Page 1 of 1