Tag Archives: programming

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.

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.

Technical Skill Semantics.

This entry is going to be a bit rough on me. As someone who dislikes technobabble with excessive terminology and classification this entry is going against my grain.

You see, I’ve been looking for some casual contract type of work and find myself a bit uncertain as to how to rate or grade my skills.

Using some of the terms found in ads I wonder, am I a Ninja? Is a Ninja better than an Expert? Obviously a Guru is much more skilled and knowledgeable than an Expert. It takes years and strict training to become a Guru and I know I’m not that in any technical abilities.

So, should I consider myself a Star? I would sure like it if everyone called me Star. Better yet, Super Star! I assure you I am not a Rock Star and I don’t know what that has to do with web skills let alone what a Wizard does.

One thing I am certain – I’m not is a Fiery Dancing Faerie Master! OK, I admit I just made that one up.

It could be my age as I’m now deep into my thirties. I’m pretty good at understanding terms such as ‘basic knowledge’, ‘good’, ‘understanding’ and ‘excellent’. I do start to waver a bit with the semi-obscure or relative terms such as ‘intermediate’, ‘advanced’, ‘experience with’, and ‘expert’.

I further admit to finding it confusing when someone is advertising a ‘Junior’ position with a list of 10 or more different major skills. Another speed bump for me is ‘expert’. There is no way we have millions of experts and all willing to work for $10 to $15 an hour according to the ads. An expert to me is someone who has mastered their chosen profession, who lives and breaths it, someone who can school a teacher.

So my point as you may be wondering is that we need a good Technical Skill Rating system to gauge proficiency. You know, like the standard trade skill apprentice, journeyman and master. Something of that like. Is there something out there I, and most companies, don’t know about?

So back to my search where I can at least feel safe in understanding what ‘Local’ means.