Use a UDT for content styling

  Previous article Next article  

Use a UDT for content styling

  Article optimized for CMSMS 2.x

  Author:
  Last tested in: CMSMS 2.2.2
  Last updated: 25-07-2016
  Comments: 0

A User Defined Tag (UDT) in CMS Made Simple™ is a small piece of PHP-code (without <?php and ?>) that can be called with just a short {SmartyTag}.
Using PHP-code for styling a content page or blog article is probably not the first thing that comes in mind. But because of the easy way to name and call the UDT, and the flexibility of its content it is very useful!! Okay, you *do* need a little bit of understanding how to create a line of PHP with single and double quotes...

Here at my blog I use <h3> blocks for subtitles. But I have different kinds of them, and they have different images attached (Font Awesome). Doing this in HTML isn't an option, to complex...

I created a few UDT's which I can place in the content where I want without any fuss.

  How to use

The "How to use" title
{how_to_use}
UDT content "how_to_use"
echo '<h3><i class="fa fa-gears" aria-hidden="true"></i>&nbsp;&nbsp;How to use</h3>';

  Working example

The "Working example" title
{working_example}
UDT content "working_example"
echo '<h3><i class="fa fa-desktop" aria-hidden="true"></i>&nbsp;&nbsp;Working example</h3>';

 Example title with anchor link

Create anchor links to titles
<h3>{insert_anchor name='subtitle'}The subtitle</h3>
UDT content "insert_anchor"
$name = isset($params['name']) ? $params['name'] : 'anchor';
$url = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]#$name";

echo '<a name="' . $name . '" title="Open an anchor link to this point in the page" href="' . $url . '"><i class="fa fa-link"></i></a>&nbsp;';

Note: These are just a few examples that work for me! You should adapt or create your own for your need and wishes. The reason I post them is to give you a headstart on an alternative method to the regular styling.



A2 Webhosting CMS Made Simple

  Comments

  Click here to leave a comment






This is a captcha-picture. It is used to prevent mass-access by robots. (see: www.captcha.net)
  « Enter the CAPTCHA code (lower case)

Your IP address will be stored on submit. I reserve the right to change or delete your response without notice!
In case of abuse your IP address will be blocked!


Can I have your attention for a moment?

Did this tutorial help you solving a problem at your (clients) website and it saved you many hours of work? Great!!
Consider buying Rolf a cup of coffee in return! [ Click here ]


  0 Comments

No comments yet...

CMS Made Simple 2.2.2 - Tutorials, tips and tricks - CMSMS 2.2.2

Use a UDT for content styling

  Article optimized for CMSMS 2.x

  Author:
  Last tested in: CMSMS 2.2.2
  Last updated: 25-07-2016
  Comments: 0

A2 Webhosting CMS Made Simple