Introducing the 2015 Textpattern tag tutorial series

admin-ajax

As 2014 draws to a close, my writing desk in the northern hemisphere is getting more attention. The daylight hours are shorter and I spend more time at my computer because of this. With that in mind, I’m embarking on a project to tell you more about Textpattern CMS tags. Tags in instructions to Textpattern to do certain stuff. I covered some high-level stuff associated with tags back in January 2014, which you can (re-)read at your convenience:

To get the most of this tutorial series, which will take place from January 2015 to June 2015, and possibly extend further if the feedback is good, I recommend reading the above articles first. The aim of the articles listed above is to provide a broad overview of the fundamentals. What I wrote nearly a year ago is still valid and holds true; the method of using Textpattern tags hasn’t changed in that time, although the list of tags and their respective attributes is gradually increasing.

Throughout this series, I will be covering Textpattern tags and their attributes. You are not expected to commit all these to memory. To aid your understanding and learning, I’ve made an at-a-glance table of all the Textpattern tags and their current attributes in a Google Sheet here:

I would reproduce it here, but frankly it’s massive and would be too cramped to be usable. In the event of a new Textpattern release with additional or modified tags/attributes, that table will be updated. With that in mind, you can safely add it to your bookmarks if you intend to become more familiar with the Textpattern’s tagging syntax.

There are 160+ tags, each with their own set of attributes, and each one of my upcoming articles will cover one or more tag from the list, along with some or all of the attributes. I won’t be explaining each facet of every single tag; if you have any questions or queries about anything I’ve written, or wish to select a tag for an upcoming article later in the series, leave something in the comments and we’ll figure something out. If you’re keen to find out more and don’t want to wait for a reply from me, you should also refer to the Textpattern tag reference on the Textpattern documentation wiki.

Each article will include practical examples of how you can use the tag and its attribute(s) on your Textpattern instance, as well as tips and advisories to get the most benefit from it. Each Textpattern site is different, but many of the tags can benefit you directly. Finally, to whet your appetite for January 2015, here’s what I have planned:

  • txp:custom_field
  • txp:category1 & txp:category2
  • txp:article
  • txp:article_custom
  • txp:posted, txp:modified & txp:expires

January 2015 is all about article tags, which will help you make the most of your written words. I do hope you can join me.

Looking for quality Textpattern Hosting? Look no further than Arvixe Web Hosting and use coupon TEXTPATTERN for 20% off your first invoice!

Tags: , , , , , , , , , | Posted under Textpattern | Leave a comment

Opencart – PHP Coding (require_once)

This is the second part of what will be many articles on PHP coding as it involves Opencart.  This article is on a very common usage in php called require_once. I chose this because it is used in Opencart very ubiquitously and in general a very common PHP declaration.

The list of require functions:

  1. -include
  2. -include_once
  3. -require
  4. -require_once

What is require_once?

The last of the four functions used to include particular pages is the require_once, which is a combination of the require and include_once function. This will make sure that the file exists prior to adding it to the page if it’s not there it will throw a fatal error. Plus it will make sure that the file can only be used once on the page. This is very handy in many situations

This function is the most strict out of the four functions and is the function I use most when constructing the page. Going back to the example used in the include function the require_once function is what you should use when displaying things like the website header and footer. This is because you always want these files to be here if they are not here you want the site to error, and you only want these to appear once on the page.

Here is a generic example of why you would only want the include to show once on the page and why require_once can be useful:

require_once 'header.php';

<div id="content">

</div>

require_once 'footer.php';

In that example you really only want the header and footer to show one time.

Now let’s take a look at how a require_once is used in Opencart. Go to the following file: /index.php

Once in that file you will see quite a few require_once’s but find the following:

// Startup
require_once(DIR_SYSTEM . 'startup.php');

Since this is in the index.php it is sure to be called on “every page load”. Sometimes people use require_once to load entire templates into existing pages as well.

Important side notes to take notice of:

If your code is running on multiple servers with different environments (locations from where your scripts run) the following idea may be useful to you:

a. Do not give absolute path to include files on your server.
b. Dynamically calculate the full path (absolute path)

Hints:
Use a combination of dirname(__FILE__) and subsequent calls to itself until you reach to the home of your ‘/index.php’. Then, attach this variable (that contains the path) to your included files.

One of my typical example is:

<?php
define('__ROOT__', dirname(dirname(__FILE__)));
require_once(__ROOT__.'/config.php');
?>

Instead of:

<?php require_once('/var/www/public_html/config.php'); ?>

After this, if you copy paste your codes to another servers, it will still run, without requiring any further re-configurations.

Lastly, here is a nifty MOODLE diagram of what happens when you include a config file.

Moodle_startup

Looking for quality OpenCart Web Hosting? Look no further than Arvixe Web Hosting!

Tags: , , , | Posted under OpenCart | Leave a comment

Increase Upload File Size in Joomla

Joomla has a preset size for each file you want to upload into your Media Manager, this size is set to 10 Megabytes (MB) but you can increase it easily by following a few simple steps. In this article I will explain how to increase upload file size in Joomla. Learn More

Tags: , , , , , , , , , , , , , , , , | Posted under Joomla | Leave a comment