A Free Template From Joomlashack

A Free Template From Joomlashack

Hacks


Troubleshooting MySQL queries in MAMP PDF Print E-mail
Written by Kirby   
Friday, 30 January 2009 01:04

Here's a MAMP specific hack for finding what MySQL queries are killing your application.

First, backup /Applications/MAMP/bin/startMysql.sh

Next, pop open /Applications/MAMP/bin/startMysql.sh in your favorite text editor
You should see something like this:

# /bin/sh
/Applications/MAMP/Library/bin/mysqld_safe --port=3306 --socket=/Applications/MAMP/tmp/mysql/mysql.sock --lower_case_table_names=0 --pid-file=/Applications/MAMP/tmp/mysql/mysql.pid --log-error=/Applications/MAMP/logs/mysql_error_log &

You want to add in this string to that command:
--log-slow-queries=/Applications/MAMP/logs/slow_query_log

So the file contents should look like:

# /bin/sh
# /bin/sh /Applications/MAMP/Library/bin/mysqld_safe --port=3306 --socket=/Applications/MAMP/tmp/mysql/mysql.sock --lower_case_table_names=0 --pid-file=/Applications/MAMP/tmp/mysql/mysql.pid --log-slow-queries=/Applications/MAMP/logs/slow_query_log --log-error=/Applications/MAMP/logs/mysql_error_log &

Save out the file, restart MAMP, start hitting pages and monitor the file, /Applications/MAMP/logs/slow_query_log

This should be fine for MAMP 1.4.1. YMMV may vary, depending on your MySQL version. The concept is the same, but the syntax can change in later versions.

 
Small Virtuemart tweak for SEO PDF Print E-mail
Written by Kirby   
Saturday, 20 December 2008 23:23

You might want to implement this tweak to your Virtuemart files in order to avoid Google complaining about your product pages containing identical meta descriptions.

I am not a Virtuemart expert and I might end up finding a config that gets around this. However, when I first set up my store I noticed that the product pages all contained a default meta description. The category pages grabbed the category descriptions just fine but the product pages needed help.

Open up /components/com_virtuemart/themes/default/templates/product_details/flypage.tpl.php in vi/emacs/TextEdit/whatever. All you need are the following 2 lines:

$document =& JFactory::getDocument();
$document->setDescription($product_name . ": " . strip_tags($product_description));

I would place these near the top of the file, possibly just after

mm_showMyFileName(__FILE__);

 
Load Mootools modal window immediately in Joomla PDF Print E-mail
Written by Kirby   
Wednesday, 26 November 2008 18:52

Modal windows using Mootools are pretty useful. It's great to include AJAX effects and functionality easily within Joomla.

I was recently tasked with creating a popover form, but the catch was that it had to load automatically. A quick post to the Joomla forums didn't yield an immediate response (...not that the forums aren't great but I needed some advice very quickly. As I write, there's probably someone typing in better code than I have here...). AJAX isn't a strong point right now. I kind of wish I had a couple weeks (or months) to just tinker with AJAX so it's more familiar.

Anyway, I got some initial wisdom from the pages of Art of Joomla for how to include the usual modal windows using Mootools within Joomla. This was a start.

The difference though was how to get this stuff to load without a click event. Also, I needed a window that opened a real page.

  1. You still need to include this at the top of your template:
    <?php JHTML::_( 'behavior.modal' ); ?>
  2. Next, you still need to create a link that represents what URL you want, plus the rel attribute that gives the specs for the iframe.
    <a class="modal" rel="{handler: 'iframe', size: {x: 570, y: 500}}" id="modalWindowLink" href="http://www.kirbymixedmedia.com"></a>
    For this project we didn't want a visible link. I just didn't put in any text in between the link tags. I'm guessing you could set the css visibility if you think that's cleaner. I also gave the link a specific ID.
  3. Finally, this is the code block that gets it done.

    Just after the link, I put in this script block:

          <script>
    window.addEvent('domready', function() {
    window.addEvent('load', function(){
    //alert('clicked!');
    SqueezeBox.fromElement($('modalWindowLink'));
    });
    });
    </script>

    (commented line is just for debugging.)

Load your page, cross your fingers and watch the modal window pop up.

Clean up this code, tweak, improve - have fun!

 
Using GIMP to Create Graphics for RokSlide PDF Print E-mail
Written by Kirby   
Sunday, 23 November 2008 23:36

Every Joomla-head knows about RocketTheme and the great templates they've created. I recently started using the Replicant template for DeathBeaver and needed to customize the icons for RokSlide.

1. Create an image within a 114px by 114pixel square within the GIMP. Save it to whatever.png.
Create File

2. Go to the top menu, Image and click Canvas Size. Set the canvas to 124pixels wide by 194pixels tall. Make sure to click the little chain link nex to the inputs where you set the sizes. Otherwise, it won't allow you to set an uneven proportion.
Expand CanvasSet Canvas Size

3. Use the Move tool to set the white square so that about 5 pixels spacing are on the top, left and right.
Space graphicCreate File

4. Place whatever art you're trying to display within the 114x114 space.
Add art

5. OK, here is where it gets tricky to describe. Believe once you get the hang of this you could churn these out quickly. Anyway, open up the Layers, Channels and Paths dialog from the top Windows menu. You should see one layer you're working on called Background. Click the "Create a duplicate..." button in that window. It looks like a couple of picture frames on top of each other.
Duplicate layer

6. Use the Flip tool to flip that layer vertically. Use the Move tool so that the top of the image that's been created is touching the bottom of the original image. Set the transparency of that layer within the Layers, Channels and Paths dialog. I used 26.6% but eyeball it and see how it goes.
Move, and set transparency for duplicate layer

7. OK, make sure you're working on the right layer for this. Click on newer layer within Layers, Channels and Paths. Do a Select All (cntl-A or Edit->Select All). In GIMP 2.6, I use Shift-Q for Toggle Quick Mask. You can also get to that option from the Select top menu. Select the Gradient tool from your Toolbox window. Select black for the Foreground color. Then, within the Gradient tool options, select the FG to Transparent gradient. Use the gradient tool by by click once where the "reflection" begins and drag downward. Toggle Quick Mask again. You've used the gradient as a mask so when you apply Clear, anything that's black is completely unaffected and pixels that are shades of gray are affected according to how dark it is. Select Edit->Clear. Ta Da!
Setting maskMask sets selection when Toggle Quick Mask is selected againClear takes out pixels depending on the mask

8. Save and upload to wherever makes sense on your site. You can then reference this graphic within your RokSlide module (which is really a mod_custom with some javascript thrown in...).

 
MVC, SEO and Joomla PDF Print E-mail
Written by Kirby   
Friday, 21 November 2008 20:35

Joomla has come really far SEO-wise since the 1.0.x branch, but you can tweak your layouts further using the MVC capabilities of 1.5.

'What is MVC?', you might ask. Well, you can read about it or you can accept my really overly short summary that would probably incite vicious all-caps comments if I put them on the site... Anyway, MVC is a way of building an application that allows for easy edits to the display of your pages. The guts of the application have been made separate so if you want to tweak things without butchering the rest of the program, you can. For 90+% of us tweaking Joomla, this explanation is good enough.

One of the quick issues to fix is the fact that your Joomla article title are not surrounded by H1 tags. Typically you'd want something that summarizes your points, like the headline/title, to have H1 tags. In order to do this without Joomla 1.5's MVC approach, you'd have to hack /components/com_content/views/article/tmpl/default.php. This in turn would mean, that unless you stayed pretty vigilant, any point releases (updates) that came from Joomla might replace your custom code changes. And if you made any more tweaks to other areas of Joomla, you'd have to be that much more on top of what the updates were, well, updating.

Luckily, we don't have to hack the sacred core code.

Copy, through FTP, the command line - whatever, this file /components/com_content/views/article/tmpl/default.php to /templates/<whatever template you're using>/html/com_content/article/default.php. So /templates/<whatever template you're using> is already going to exist. You'll have to probably create the directories com_content and article within your template directory. I say 'probably' because for whatever reason you might have installed a template which the template designer already understood the MVC concept or someone has already made customizations.

In any case, once you have copied this file to the above desitnation, you're practically done. Now you can hack with (almost) total impunity. If you really screw stuff up, you could just rename your hacked file to default.bak.php and it won't get recognized and Joomla will go back to using the normal default.php for your articles. Or, if you're that frustrated, you can delete your copy and go back to playing WoW.

So, you can do whatever you need to for SEO or non-SEO purposes. I made the aforementioned H1 edits:

<?php if ($this->params->get('link_titles') && $this->article->readmore_link != '') : ?>
<a href="/<?php echo $this->article->readmore_link; ?>" class="contentpagetitle<?php echo $this->params->get( 'pageclass_sfx' ); ?>">
<?php echo $this->escape($this->article->title); ?></a>
<?php else : ?>
<?php echo $this->escape($this->article->title); ?>
<?php endif; ?>
becomes:
<?php if ($this->params->get('link_titles') && $this->article->readmore_link != '') : ?>
<a href="/<?php echo $this->article->readmore_link; ?>" class="contentpagetitle<?php echo $this->params->get( 'pageclass_sfx' ); ?>">
<h1><?php echo $this->escape($this->article->title); ?></h1></a>
<?php else : ?>
<h1><?php echo $this->escape($this->article->title); ?></h1>
<?php endif; ?>

I also use this to set my meta descriptions:

$document =& JFactory::getDocument();
$description = substr($this->article->text,0,strpos($this->article->text,'</p>'));
$document->setDescription( trim(strip_tags($description)) );

That block is definitely experimental. It basically takes the first paragraph and makes it the meta description for the page. "Now why the hell would you do that?", you might ask. Well, first, because I like to tinker and second because I'm lazy and just like to write my article and not worry about adding in the description in the article page. And third, because from what I know, Google likes there to be some similarity between the description and page content.

Happy Joomla'ing!

 
<< Start < Prev 1 2 Next > End >>

Page 1 of 2
Joomla 1.5 Templates by Joomlashack