How to Implement {script}folder/file{/script} - php

I am looking to build a plugin for Joomla that will allow me to play video using HTML5 first before resorting back to Flash. In my effort to make this plugin in more dynamic I would like to have an easy way of embedding the video. In similar plugins I have seen where the user can put in a specific phrase surrounded with brackets. Something similar to the following:
{html5video}media/video{/html5video}
What is this method called and where can I find more information on how to implement it into a plugin?

As per my knowledge there is no specific term defined in Joomla for this method, but those who are much familiar with Wordpress calls it SHORTCODE method
You will need to create a content plugin -
use regex , php preg_match_all and extract this string and replace with your desired code.
One such plugin is available in Joomla. You can check it in plugins\content\loadmodule
You may need to modify the regex pattern used in this plugin

Related

Shortcodes for non-wordpress custom CMS

Trying to implement my own "shortcode"-type system on my cms.
substr() can possibly work as long as there isn't more than one shortcode in the content. I can't use <?php ?>, but must use a WYSIWYG type editor for entering in the shortcode, since it is the enduser who will be entering them via the content editor.
If someone enters a "Shortcode" that follows the rules I set, this class function will discover the shortcode, parse it and then replace the shortcode with other data pulled from mysql or another source.
I can get this to work, essentially no problem, if there is not more than one single shortcode entered into the content via WYSIWYG, but more than one and it breaks.
I've looked all over the internet for this and found various things, but most of them deal with Wordpress and the few that don't aren't approaching it as I need to. Found one threat on StackOverflow which provides a potential approach that I could use, but I really need advice and a place to start more than a full function. The Wordpress Shortcode system isn't helpful either.

Would it be possible to create your own semantic markup "<something></something>" for you template engine in PHP?

I would really appreciate if anybody could help me with this question :)
I want to know whether it's possible to create your own semantic markup in PHP, just like BB Codes, but I want to be able to use it within my template engine system, so I could use it to call custom modules like voting system, adding comments, login form, registration form and so on...
Let me make it clearer for you guys of how I mean;
I'm working on my own CMS not to use it for production purposes but to learn PHP in a better way;
So I had this idea to call specific modules in a page based on their position and in order to be able to do;
For instance we're having a login module which is simply a login form, nothing too crazy, however you want to be able to include that module dynamically in any page you want using the backend and not touching any code;
So all you do in the template page is using my bb codes that I told you earlier;
Something like this;
Remember this is only an idea;
<zone name="left_sidebar"></zone>
And you add this zone markup on your sidebar and if any of your module supposed to be displayed on your left sidebar, it will just by having this markup and nothing more...
And you gone have loads of these semantic markups based on how many editable blocks you have on your page; so you could have one for the right sidebar, one for footer and one for header... etc.
So I now need to know how to could lookup for opening and closing tags, in this case it would be <zone></zone> , then it need to lookup for its attribute and its value, in this case name="right_sidevar"
....
Anybody have any idea of how I could possibly do this kind of thing...
Thanks in advance :)
You could check out TWIG; while it doesn't directly support this kind of feature (because it uses a special syntax for its own elements) it does have very good support for making your own elements, tags, sub-applications and other funky things in the backend.
http://twig.sensiolabs.org/
There are also a number of systems that perform this kind of task in the front-end; this would mean that the substitution is done by Javascript in the browser. In addition to the already mentioned Polymer, there's also Google's framework, Angular.
https://angularjs.org/
Maybe you can use php's libxml module to parse your xml file.

conflicting functions when using two includes (mybb and wordpress)

I use MyBB for forum and Wordpress for blog. When I try to integrate both together into a page, I get conflicts between functions. The forum header and the wordpress includes have some functions with the same identifier.
I need both functions but I obviously can't change the name of something inside wordpress or mybb.
What are the solutions to these conflicting problems?
Can I deinclude an included file?
If I could use iframe then it wouldn't look good with the scrolls and the border. If this is the only way then how can I remove the border and the scrollbars so that it would look exactly the same when the code was in the original page itself?
First of all: That is a hell of a task.
Still thou, if you aim to do it, read up on namespaces.
I figure it is possible to add those to all wordpress classes and all myBB classes.
You would have to do a lot of rewriting, but some search and replace tools using regular expressions should be able to help you with that.
You could also try to havew them seperately (yourdomain.com/myBB and yourdomain.com/wp) and integrate them via webservices. So you myBB would access wordpress data via RSS?

How to make a custom markup language/parser in Codeigniter?

I'm working on a custom CMS in Codeigniter and I'm trying to allow users to use custom tags instead of having to place HTML into posts.
For example, if a person is posting about a game and want to include a stylized button as a call to action, they would just type [button=http://example.com]Play this game[/button] instead of the HTML <div class="action-button">Play this game</div>
Obviously, this is a simple example. Some more complex things I'd like to do would be something like [gallery=120] which would include an image gallery with an ID of 120.
I've been searching and I haven't had much luck. I feel like there's another word for what I'm trying to do but it's just not coming to me, maybe that would yield better search results.
Any tips to get me going would be appreciated.
The term you're looking for is BBCode (Bulletin Board Code).
As for parsing you could look at some forum apps and perhaps CI's template parser for inspiration. Like Jarrett already mentioned they mostly utilize str_replace() and preg_replace() functions.
Something like [gallery=120] would be more advanced though.
The short answer would be STRING and REGEX replace statements.
If your familiar with the CMS associated with CodeIgniter, that is, ExpressionEngine, it parses the templates using str_replace() and preg_replace().

Parse CFML tags in PHP

Background:
I have been running a site on the blogger platform for the past 5 years. I was using the option of hosting the site on my own server, publishing via FTP. My server is running ColdFusion, so I decided to take advantage of that. I created Coldfusion custom tags that provided additional functionality and included those in many of may posts -- to be clear, the body of my posts. Google decided to shut off access to this FTP publishing option. I took that news as an excuse to move to WordPress. Now I have to figure out what to do about all of those ColdFusion tags in my posts.
Problem:
I'd like to not loose the functionality provided by the custom tags I have embedded into my posts. My primary question is what's the best way to add functionality to a PHP site using custom tags? My initial plan was to try parsing the page to find the tags, then write a PHP class to basically mimic the functionality that was provided by the Coldfusion file. I don't know much about PHP, so I'm not sure what tools or libraries are out there to facilitate that. Or if it's just a foolish idea. These are not well formed XML files, so I need something fairly robust.
Example:
I use the following tag:
<cf_taglinks>Tag1, Tag2, Tag3</cf_taglinks>
to generate a series of <a..>Tag#</a> elements that link to technorati or whatever I decide (thus the benefit of having a custom tag - very easy to change behaviors). The solution for this problem could really be able to handle any link, so if I have a <stackoverflowLink post="3944091"/> tag, I should be able to translate that into
<a href="http://stackoverflow.com/posts/3944091/"
target="_blank">Stackoverflow Question: 3944091</a>
Right now I'm leaning towards the Custom Tags library mentioned in this post as the answer. One of the best features is support for buried or nested tags like the code block below:
<ct:upper type="all">
This text is transformed by the custom tag.<br />
Using the default example all the characters should be made into uppercase characters.<br />
Try changing the type attribute to 'ucwords' or 'ucfirst'.<br />
<br />
<ct:lower>
<strong>ct:lower</strong><br />
THIS IS LOWERCASE TEXT TRANSFORMED BY THE ct:lower CUSTOM TAG even though it's inside the ct:upper tag.<br />
<BR />
</ct:lower>
</ct:upper>
I highly recommend downloading the zip file and looking through the examples it contains.

Categories