MENU

Use a UDT for content styling

  Previous article Next article  

A User Defined Tag (UDT) in CMS Made Simple™ is a small piece of PHP-code (without ) 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.



Buy Me A Coffee


  Comment Form

ReviewManager

Click here to open the form

ReviewManager

  0 Comments

No comments yet...

Buy Me A Coffee

CMS Made Simple - Tutorials, Tips and Tricks - CMSMS

Use a UDT for content styling

  Article optimized for CMSMS 2.x

  Author:
  Last tested in: CMSMS 2.2.19
  Last updated: 23-06-2018
  Comments: 0
  http://cms.ms/pXhr


Buy Me A Coffee




Advertisement


Ads help me to help you! Thanks!

Ads help me to help you! Buy products from these advertisers!