Tag Archives: development

Mihalism Multi Host: Ads or Content in Public Gallery Section

This is a very simple modification for Mihalism Multi Host (MMH) that will allow you to include content interspersed in the public gallery section. Provided is a simple method that includes content on each row in the gallery and in a random position of that row.

This mod does not include content in the user galleries or in the admin section but it would be simple enough to do for them. Further, adding content in an ordered way and at set intervals, could also be done with ease.

This example is based on a four column table (which is standard and hard coded in MMH). Ok, lets get down to it:

Step 1, Create a template file for the content you want to insert:

In the directory source/public_html create the file global_ad.tpl in this file include the following:

<!– BEGIN: GLOBAL GALLERY AD LAYOUT –>

<template id=”global_gallery_ad_layout_1″>
<# TABLE_BREAK #>
<td class=”<# TDCLASS #>” valign=”top” style=”text-align:center;”>
<strong><# FILE_TITLE #></strong>
<br /><br />
Sample Text #1 – Replace with text, markup or javascript
</td>
</template>

<template id=”global_gallery_ad_layout_2″>
<# TABLE_BREAK #>
<td class=”<# TDCLASS #>” valign=”top” style=”text-align:center;”>
<strong><# FILE_TITLE #></strong>
<br /><br />
Sample Text #2 – Replace with text, markup or javascript
</td>
</template>

<template id=”global_gallery_ad_layout_3″>
<# TABLE_BREAK #>
<td class=”<# TDCLASS #>” valign=”top” style=”text-align:center;”>
<strong><# FILE_TITLE #></strong>
<br /><br />
Sample Text #3 – Replace with text, markup or javascript
</td>
</template>

<!– END: GLOBAL GALLERY AD LAYOUT –>

The above code allows for three different content items. You can include markup, javascipt or straight text by replacing the text shown in bold: “Sample Text – Replace with text, markup or javascript”. How many content items you want is up to you. Adding another is as simple as copying one of the template sections and changing the end number in template id. To have fewer just remove the template markup for one or more items.

Step 2, Add the code to insert content:

In the root directory you will find the file gallery.php – load this with your favorite editor to get down to hacking.

  1. On or near line 20, just before the while loop: while ($row = $mmhclass->db->fetch_array($sql)) { insert the following: $ad_place_in_row = rand(1,4); // Get random position for ad on first row
  2. Just bellow the while loop there is an if condition with the line: $break_line = true; Right after that add the following: $ad_place_in_row = rand(1,4); // Reset random position for new row
  3. Now, just after the while loop you will see the line: $tdcount++; add the following block of code after that line (now aproximately line 28/29):
  4. /* begin ad placement */
    if ($tdcount == $ad_place_in_row) {

    $mmhclass->templ->templ_vars[] = array(
    “FILE_TITLE” => ‘Title of Content (or empty)‘,
    “TDCLASS” => $tdclass = (($tdclass == “tdrow1”) ? “tdrow2” : “tdrow1”),
    “TABLE_BREAK” => (($break_line == true) ? “</tr><tr>” : NULL),
    );

    $ad_number = rand(1,3);
    $gallery_html .= $mmhclass->templ->parse_template(“global_ad”, “global_gallery_ad_layout_$ad_number”);
    unset($mmhclass->templ->templ_vars, $break_line);

    if ($tdcount >= 4) {
    $tdcount = 0;
    $break_line = true;
    $ad_place_in_row = rand(1,4);
    }

    $tdcount++;
    }
    /* end ad placement */

In the code in section C of step 2 you may notice the assignment for “FILE_TITLE” – here you can add a standard title that will display above your content.  Replace the bolded text with your preferred title.  You may also remove all the bolded text and just leave the two single quotes to have no title. Further, you can remove that whole assignment and replace the <strong><# FILE_TITLE #></strong> in the template file to a title you want.

If you have opted to have more or less items in the template file be sure to update the random ad_number: $ad_number = rand(1,3); to accommodate how many content items you have in your template. If you’ve decided to have just one item you can remove the random code and edit the line right after it: $gallery_html .= $mmhclass->templ->parse_template("global_ad", "global_gallery_ad_layout_$ad_number"); to $gallery_html .= $mmhclass->templ->parse_template("global_ad", "global_gallery_ad_layout_1"); to allow for just one item.

Step 3, Bask in the glory of happiness:

Thats it.  It is as simple as that.

As you most likely noticed the code included in gallery.php is almost exactly the same as the existing code.  This may not be the prettiest or most efficient way to do it but the reasoning behind it was to keep the mod as easy and unintrusive as possible.

If this ends up useful for someone and there is the need I can include a file for download.  I could also provide  further examples such as including the content at a set interval, if desired.  Oh, and please let me know if this made any sense at all.

I’ve Decided to Dew the Drop

What do you think of that witty little title? You get it, don’t you? The Drop, from Drupal. Dew as in Dewdrop but meant as do (that’s a homophone y’know). Pretty cute, huh?drupliconsmall.png

Alright, I’ll explain. I have chosen to use the PHP based content management system (CMS) Drupal for one of my projects. This may not seem like a big deal to you but it is for me. You see, I have a small problem. I end up spending massive amounts of time trying to figure out what tools I should use for each project. This was no exception.

The project is a gaming related site with a specific focus. I admit I was able to create a shortlist right off due to continued research on CMS’s and PHP Frameworks. The shortlist consisted of: Drupal, Joomla!, CodeIgniter or MODx.

I will introduce each and explain the major factors that lead to my decision.

MODx CMS and PHP Application Framework

MODx was awarded by Packt Publishing the “Most Promising Open Source Content Management System” in the 2007 Open Source CMS Awards.

MODx is a very interesting project which is targeting the Web 2.0 audience with an AJAX library, SEO focus, web standards compliance and cross browser compatibility among other things. It is an open source project with the standard no-nonsense GPL.

The decision against MODx was mostly due to the current rewrite of the core code. As of writing the official release is 0.9.6.1. There is a newly rewritten core on the way and slated as version 0.9.7. In my opinion this is a major problem with many CMS’s and Frameworks. Often these open source projects are in constant flux due to major revisions.

The small part of me that is a geek feels excited about MODx but I don’t feel comfortable starting a project with what could be an outdated and unsupported code base ala 0.9.6.1. Further, who’s to say how long it will take 0.9.7 to become stable and what kind of backwards compatibility will it have? I’m not sure this was a great plan right after winning the most promising CMS award.

Joomla!

Joomla! took “Best PHP Open Source Content Management System” and came in second for “Overall Open Source Content Management System Award” in the aforementioned Packt Publishing Awards. Joomla! started as a fork of the Mambo CMS and has been working at making a name for itself ever since. Joomla! has two versions available at this time: 1.0.15 and 1.5.1. Both are licensed under GPL.

Version 1.0.15 maintains a certain compatibility with Mambo to allow for use of the large assortment of Mambo/Joomla extensions. A large focus on the project has been a steady move away from its Mambo beginnings. That move has resulted in Joomla! version 1.5.1. The latest version includes an object oriented API, split of logic from presentation, search engine friendly URL’s out of the box (about time) and several other changes, additions and goodies.

Again, therein lays the big problem. 1.5.1, in comparison, is a new code base with limited usable extensions. Even some die hard Joomla! fans recommend staying away from 1.5.1 until the community can catch up and provide ample offerings for it. Starting a major project with 1.0.15 may cause additional problems and considerations if the need to upgrade arises.

I do like Joomla! for its sheer simplicity and ease of use. You can have a good solid working CMS up and out the door in no time. It reminds me of a new generation of the old Nuke CMS’s where there is a large user base constantly adding to the project. The Joomla! project is a beast that is only going to get bigger and better.

CodeIgniter PHP Application Framework

CodeIgniter is not a CMS. It’s an open source library type framework for PHP programmers with a very liberal BSD like license. CodeIgniter (CI) is a great framework with excellent documentation that provides a simple and lightweight collection of libraries. It is not overly abstracted, has a very short and easy learning curve, needs minimal server requirements and moves like greased lightning compared to many other PHP frameworks. The CI team does its best to maintain backward compatibility to allow for easy transitions to new releases. This, to me, is a major plus that many open source teams are missing.

I really don’t have anything bad to say about CI. The main reason I decided against it is the amount of time involved to build the application. There are a few CI based CMS’s that are just surfacing. I will keep a close eye on them for this and future projects. Until then, I’ll be working with Drupal.

Drupal

Finally, that leaves us with my decision. Drupal is a PHP based CMS which was awarded “Overall Open Source Content Management System Award” and took second for both, “Best PHP Open Source Content Management System” and “Best Open Source Social Networking Content Management System” in the Packt Publications 2007 contest.

Drupal is currently offering two versions, 5.7 and 6.1, both under GPL. I have opted for the older 5.7 due to module compatibility. Drupal provides a way to upgrade from 5.7 to 6.1 so instead of trying to run 6.1 with legacy code I will upgrade as the modules do. I am confident Drupal will continue to provide a solid and reliable way to move forward.

That leads to a serious plus for Drupal. The team is dedicated to a rock solid core and they seem focused with a steady development plan. I don’t have to worry about newly rewritten cores or drastic changes every few months. The Drupal project has that ‘old reliable’ feeling, one that is not riddled with surprises and upsets.

What has kept me away from Drupal is the learning curve. Drupal does things its own way using its own terminology. I’d say it is very unlikely someone new to Drupal could churn out a fully featured website in the same time a new Joomla! user would. What may take a new user one day in Joomla! may take a week in Drupal.

On the flip side, after that week with Drupal you are left with a sense of awe at its flexibility and potential. Sure, it is still awkward in many ways but it can be a powerful system to work with.

Another plus for Drupal is reports of an excellent API. I haven’t dove into that yet but expect I will soon.

A note for developers and designers both Drupal and Joomla! can open doors to additional opportunities. I often see local contracts for developers and designers familiar with Drupal or Joomla!. Sometimes both.

If you’re looking for a flexible and reliable CMS I would strongly recommend giving Drupal some time. I have found the online documentation to be spattered throughout the site. Often it is not very enlightening especially for modules. If you want to give Drupal a shot I would recommend checking out a Drupal book from your local library to help you along.

CodeIgniter 1.6.1

Obviously I’m not on the ball with this one as the CodeIgniter team popped out another release, version 1.6.1, on Feb 12, 2008.

1.6.1 is consider a maintenance release but it does include some interesting new features such as active record caching and a path helper.

The official release text and link to changelog can be viewed at http://codeigniter.com/news/codeigniter_161_released/

CodeIgniter 1.6

The latest installment of CodeIgniter (CI) Framework was announced on Jan 30, 2008.

Due to the 120+ changes the expected 1.5.5 release was passed over for the current 1.6. I won’t go into the change log as you can check out the official release yourself.

Upgrades are reported to be easy as pie. Guides can be found at: http://codeigniter.com/user_guide/installation/upgrading.html. One user posted an easy update from version 1.4 range to 1.6.

The official release forum thread which contains the standard celebration and thanks can be viewed at: http://codeigniter.com/forums/viewthread/70329/P15. So far the most interesting posts for me are from PoWah and tonanbarbarian which indicate a small increase in overhead and speed but nothing serious considering the additions.

Some 1.6 specific bugs have been trickling in on the bug report forum but I haven’t seen anything major as of yet. Most issues in the CI Bug Tracker were dealt with in this release so it is looking very clean.

As with previous CI releases there are few concerns with backwards compatibility. Further, Derek Allard, one of the CI developers has basically stated that it is fair to ‘expect tighter development cycles’ and that they already have 1.6.1 code.

If you don’t know what CodeIgniter is or haven’t tried it, I highly recommend it. In my opinion it is one of the top PHP Frameworks with boasting rights in speed, simplicity, documentation and community support. You should have no trouble in knowing what works in various versions and if you understand PHP you shouldn’t expect any serious learning curves.