Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home1/diycmsco/public_html/includes/mysql.class.php on line 82
Blog - Do It Yourself CMS

Do It Yourself CMS » Blog »

New DiY-CMs features 2: adding code to templates and imporving update system

  By: admin   tags Date Added: Wednesday 09-02-2011

In my last blog I talked about the new updates that I developed for DiY-CMS. I talked about the cache system and in this blog I will be talking about the other two new improvements, namely: adding php code to main templates and improving the update system in the control panel.

One of the most needed features was to allow code to be inserted and parsed into templates of DiY-CMS themes. Adding code provides great flexibility for designing creating dynamic themes. I have changed the way that main templates are parsed within DiY-CMS. Eval() function is no longer used for parsing as it is frowned upon by many developers due to security risks it might poses as well as its inability to parse PHP code inside templates (in the case of DiY-CMS) without number of unnecessary modifications to the CMS.

So what is the benefit of enabling code parsing within main templates? The main advantage is that creating theme would be easier and more dynamic. For instance one could use condition statements (one of the common used statements in themes) to change a colour, a column or practically anything else. One can even add functions or any snippet of code he might like to the theme that he is creating. The second advantage is that I am working of developing theme settings in which this change comes in handy. Meaning that a designer would add settings to his theme, these settings can be modified by a general user through an interface and the designer will incorporate PHP code to modify the look and feel of the theme based on these settings.

Since now PHP code is accepted within main templates one can use the standard PHP file inclusion function rather than DiY-CMS style, for instance to include the file ‘blocks/tags.block.php’ instead of using:

<!--INC dir="blocks" file="tags.block.php" -->

One could use this style:

<?php include('blocks/ tags.block.php'); ?>

I have mentioned earlier that eval() function is no longer used, and that means that variables inside the main templates will not be rendered correctly (variables are the words preceded by the dollar sing $). For example $index_middle will not render correctly and it needs to be enclosed by php tags like so:

<?php echo $index_middle; ?>

I have updated all the themes in the download center to conform to the new system, and – hopefully – you would not have problems installing or running them on your website.
The second update I will be taking about in this blog is the improvement of the update system in the control panel. I have made number of improvements to the underlying code of the system and modified it to retrieve data in JSON format from DiY-CMS official website. This will allow for a more efficient and smooth process of updates. Also I improved the system to accept ZIP files. Using this feature the website administrator would be able to install a bunch of updates in one click. In order for this feature to work you need the ZIP Library installed on your hosting server. It is mostly installed, but if it is not you can ask your hosting to install it for you.
I wish that these features would be in great help for all the user of DiY-CMS, and I hope to hear your opinions in the comments.

Tags: updates, features, php-code More details

New DiY-CMs features 1: reducing queries by 50-85%

  By: admin   tags Date Added: Wednesday 09-02-2011

After I finished programming my first app for facebook - Friends Stat, I started thinking about new ways to improve DiY-CMS. I have many ideas to develop but there are three features of them which I believe are important. They are: cache system to minimise mysql queries, adding php code into main templates and improving the update system in DiY-CMS control panel.

I will explain the first feature in this blog and then talk about the rest in later blogs.
Cache system is developed to ease the process of retrieving data from database. In other words cache system saves the results of repetitive queries that do not change often into files and then retrieve the data from these files rather that querying database again and again. As you might have guessed by now, this process will reduce the load on database and increase the cms performance.

In DiY-CMS there are number of queries that do not change often such as general settings, module settings, plugins details, themes, templates and other queries. Cache system will save the results of each one of these queries to a single file and place it in cache folder. Once a query is requested in the front-end DiY-CMS will check if there is a cache file relevant to that query and retrieve results saved in it, otherwise the query will run normally.

Cache files do not have expiry data, so files would remain for unlimited period of time. What if I make changes to settings, theme or templates? In this case the relevant cache file would be updated automatically once changes occur in the control panel. Also, you can remove cache files manually from Cache folder any time you whish and DiY-CMS will create new cache files.

This feature reduces mysql queries and therefore increases overall performance. In some pages of DiY-CMS queries reached as little as 1 query per page. Certainly the number of queries cached would be different from module to another and one page to other pages but on average mysql queries have been minimised by 50-85%. See chart below.

Furthermore, you can use this system to cache queries that you might use in modules, plugins or blocks you develop for DiY-CMS. Implementing cache is easy and requires three functions one to create the cache file, second one to check file existence.

Say we have this query that we want to cache:

$result = $diy_db->query("SELECT variable,value FROM diy_settings");

You would be place this code in the place where the data of diy_settings is updated:

// Query database table
while ($row = $diy_db->dbarray($query_result)) {
$key = $row['variable'];
$array[$key] = $row['value'];

// create a cache file and save data into it
$diy_db->create_query_cache_file('global_settings', $array);

Notice that create_query_cache_file() function takes two parameters, the first one is the file name and the second one is query data that needs to be cached.

Then you would use this code to check for the file and retrieve its data:

// check if file exists
$cahce = $diy_db->check_query_cache_file('global_settings');
if ($cahce) {
// if file exists retrieve its data and place them in a varaible
$array = $diy_db->get_query_cache_file('global_settings');
} else {
// if file does not exist proceed with query as normal
$result = $diy_db->query("SELECT variable,value FROM diy_settings");

while ($row = $diy_db->dbarray($result, $i++)) {
$key = $row['variable'];
$array[$key] = $row['value'];
// here $array data can be used as whished

In the last code snippet there are two important functions, the first one is check_query_cache_file() which checked if file exists and the second retrieve data from the cache file. Both functions take one parameter and it is the file name that we creates using create_query_cache_file() fcuntion.

I hope that this blog provides some insights into the feature of DiY-CMS and how to use them.

In next blog I will explain the rest of features.

Tags: updates-diy-cms-mysql More details

Search Module 1.0

  By: admin   tags Date Added: Wednesday 02-06-2010

Searching contents is a vital part of any website since it saves a lot of time for the visitor and for the owner of the website. I think one of the most important things that the DiY-CMS was lacking since its launch was the search part. Therefore, I programmed this search module with many options in order to make the search process very effective through any website that is using DiY-CMS.

Visitor can type any number of keywords and select whether he wants to find them all in one post or anyone of the keywords in a post. Visitor can also select where to search, in News, Forums, Downloads sections or in all of them together with the option of searching in the title or the post.

The visitor can also order the search results in Descending or Ascending order. He can also sort the results by date, number of comments, number of readers or the author of the post.

The visitor can also refine the search by choosing the time scope of the search and how many rows to display in each search results page.

Here is a screen shot for the search module index page:

And you can download it through the download area in this website.;modfile=view_file&amp;downid=12

Additionally, most of the themes that I will convert in the future will contain a search box that will not function correctly unless this module is installed in your website. (You still can remove the search box from the theme if you do not want to provide search functionality in your website).

Tags: search, modules, updates More details

Two new colors for the default DiY-CMS aqua theme

  By: admin   tags Date Added: Sunday 16-05-2010

as promised, here are two color variants of the default Aqua theme that is installed by default with the CMS. The colors are red and green. I hope you like them.

I also will post another theme called notepad chaos.

Here are the photos:
Red Theme

Green Theme

To download the themes:
Red Theme
Green Theme

Tags: theme, colors, designs, updates, red, green More details

New DiY-CMS documentation and admin area tutorials

  By: admin   tags Date Added: Friday 16-04-2010

I have two updates in this post.
First, I have added a doucumentation for DiY-CMS 1.0 using phpDocumenter. It prases comments within files and in order to gnerate documentation.
I have commented most of the files, classes and functions of the DiY-CMS execpt for the modules part which hopefully I will be commenting in the future and then upload it to the documentation.

Docuemntation can be found at:

I divided DiY-CMS into four packages:
Global: includes the main classes in the cms.
Modules: includes all the files in the modules folder.
Admin: Includes all main classes in the admin folder.
Admin Sections: Includes all files under the admin section folder in the admin area.

The style of comment will be used as the standard style of commenting files, classes or functions. For any one who is intrested to delvope additions to cms use this style.
At the page level and for classes, use this style:

* Short description of the file.
* Long desciption: you have to leave an empty line before and after this description.
* @package Name of the pacakge
* @subpackage Name of Subpackage
* @author Authour name
* @copyright Copyright notice
* @version Version Number

To comment a function you might use this style:
* Short description of the file.
* Long desciption: you have to leave an empty line before and after this description.
* @param parameter type Description of parameter. You can add as many as lines as much parameters you have in the function

* @return return type Type of the returned values

You can use other tags recognised by phpDocumenter, but I have included the minimum.

Second update is that uploaded three tutorials explaining settings and module parts of the admin area:
1- Configuring general settings in admin area

2- Modules managment, part 1

3- Modules managment, part 2

All the videos are recodered using HD.

I hope these updated will help anyone who uses DiY-CMS to make them navigate easily throught the cms. If you have any comments about the tutorials or doucmentation please do not hestiate to tell me.

Tags: diy-cms, cms, updates, phpdocumenter, documentation, tutirals, videos More details

Finally, DiY-CMS v1.0 is out!

  By: admin   tags Date Added: Sunday 28-03-2010

Finally, the diycms v1.0 is out. I spend around 8-9 months to finish this cms. Firstly it started as a fork of Arab Portl but as I started modifying the code I thought a new cms has to be born. So I started writing the code for diycms last year around July and not it is done (hopefully).

I have included many features in this cms; group permissions, modules creation and management, themes management, menus management, and many more.

I have many plans and addition for the cms in mind such friendly URLs, audio module, calendar, gallery, file manager, language manager for both the cms and its modules through the admin area, integration with free forum software such as phpbb and smf, log user activities and many more.

I will be adding a series of video lessons on how to use this cms. Hopefully, they will come out soon.

I hope you like the cms, you can download by clicking on Downlod CMS link on top of this page, or ask any question you like in the support forums.

Tags: diycms, new-version, update More details

2 3 > »