Welcome Guest, Not a member yet? Register   Sign In
wordpress shortcode for CI
#1

[eluser]umefarooq[/eluser]
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
#2

[eluser]umefarooq[/eluser]
shortcode library doc

if shortcode helper and library autoloaded then skip step 1

step 1
Code:
$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
Code:
//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
Code:
//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);
#3

[eluser]Irfan Cikoglu[/eluser]
o.O Interesting lib, thanks
#4

[eluser]Doseone[/eluser]
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.

Code:
<div style="border:1px solid #990000;padding-left:20px;margin:0 0 10px 0;">
<h4>A PHP Error was encountered</h4>
<p>Severity: Warning</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>Filename: libraries/Shortcode.php</p>
<p>Line Number: 184</p>
</div>

Any ideas on how to resolve this?
#5

[eluser]umefarooq[/eluser]
can you post your callback function code let me see what's the problem
#6

[eluser]Doseone[/eluser]
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.
#7

[eluser]Unknown[/eluser]
zip file download link is broken....!
#8

[eluser]Unknown[/eluser]
@umefarooq:
I don't know how to use it. Can you show me how to use it in a little detail ?
Thank you very much.
#9

[eluser]Lykos22[/eluser]
I'm using this Shortcodes library that helps create contact forms, maps etc etc that I 've created.

I haven't found a way though to create shortcodes with enclosed content, like the [shortcode foo="bar"]content[/shortcode] example, in order to create html content such as li tabs
and accordions.

I have also made a topic on this here where I explain with more details what I want to do.

How can I make this work? Do I need to do any changes to my library? I'd be grateful if you could give me some feedback/help.




Theme © iAndrew 2016 - Forum software by © MyBB