EllisLab text mark
Advanced Search
     
wordpress shortcode for CI
Posted: 08 July 2011 10:32 AM   [ Ignore ]
Avatar
Joined: 2008-09-11
758 posts

i really like wordpress because of shortcode, really easy to power up theme with short code like creating jquery ui tabs, accordion or image like with lightbox, or formatting your content according to your theme. i was looking for such a library for CI but really difficult to find it. i am working on a project where we want to add jquery ui tabs from backend really difficult for a normal user to add that. i googled and fond shortcode library work with CI in pastbin, here is link to that library

http://pastebin.com/6E48Cfpc

i added some extra features in this library to load defaults from config file, calling helper functions and use with CI template parser library. really thanks to unknown person for posting such a good library on pastebin all credit goes to him. feel free to add more features and your comments

 Signature 

CI,JQuery,Google Maps | widget with CI loader | Thumbnail, Image Resize, Image Crop Helper | CI shortcode

 
Posted: 08 July 2011 10:49 AM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2008-09-11
758 posts

shortcode library doc

if shortcode helper and library autoloaded then skip step 1

step 1

$this->load->helper('shortcode'); 
 
//shortcode helper should be called first so all functions available to call

  
$this->load->library('shortcode'); 

 
// you can pass array of tags and tag functions like 
  
$config = array('tag1name'=>'tag1_func','tag2name'=>'tag2_func');
  
$this->load->library('shortcode',$config); 

step 2

//if you want to add multiple short tags

  
$tags = array('tag1name'=>'tag1_func','tag2name'=>'tag2_func');
  
$this->shortcode->add_all($tags);

  
//if you want to add only one short tag
  
$this->shortcode->add(tag_name,tag_func); 

step 3 with or without CI template parser library

step 3

//with CI template parser
  
$this->load->library('parser');
  
$this->parser->parse('view_name',$data);

// without CI template parser
 
$content $this->load->view('view_name',$data,TRUE);

// this will run all shortcode function and return output string
 
$output $this->shortcode->run($content);
 
$this->output->set_output($output); 
 Signature 

CI,JQuery,Google Maps | widget with CI loader | Thumbnail, Image Resize, Image Crop Helper | CI shortcode

 
Posted: 08 July 2011 01:31 PM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Joined: 2011-06-28
42 posts

o.O Interesting lib, thanks

 Signature 
<?php
if ($this->time() == 'MONEY')
{
    
echo 'Why aren\'t we rich?!';
    exit;
}

/* End of file legitimacy_helper.php */
/* Location: ./application/helpers/legitimacy_helper.php */ 
 
Posted: 12 July 2011 10:15 AM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Joined: 2011-07-12
4 posts

hi I was testing this out, and sure enough it works well on my localhost, but when I upload the application to the live server I’m getting an error.

<div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">
<
h4>A PHP Error was encountered</h4>
<
p>SeverityWarning</p>
<
p>Message:  preg_replace_callback() [<a href="function.preg-replace-callback">function.preg-replace-callback</a>]Requires argument 2'Shortcode::do_shortcode_tag'to be a valid callback</p>
<
p>Filenamelibraries/Shortcode.php</p>
<
p>Line Number184</p>
</
div

Any ideas on how to resolve this?

 
Posted: 13 July 2011 03:50 PM   [ Ignore ]   [ # 4 ]   [ Rating: 0 ]
Avatar
Joined: 2008-09-11
758 posts

can you post your callback function code let me see what’s the problem

 Signature 

CI,JQuery,Google Maps | widget with CI loader | Thumbnail, Image Resize, Image Crop Helper | CI shortcode

 
Posted: 14 July 2011 05:34 AM   [ Ignore ]   [ # 5 ]   [ Rating: 0 ]
Joined: 2011-07-12
4 posts

The code I had used was the same code that was in the zip file, was just testing out your code. there were no changes apart from the codeigniter install was running the hmvc library. but also tested it with a fresh copy of codeigniter too still no difference.

 
Posted: 15 March 2012 03:17 AM   [ Ignore ]   [ # 6 ]   [ Rating: 0 ]
Joined: 2012-02-08
1 posts

zip file download link is broken….!