A Free Template From Joomlashack

A Free Template From Joomlashack

Hacks


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!

 
Email Cloaking (almost) anywhere in Joomla PDF Print E-mail
Written by Kirby   
Thursday, 20 November 2008 20:02

When you're using Joomla's Article Manager, you get spoiled by its email cloaking. Then you start creating modules or dealing with other areas that don't incorporate the email cloaking and it's a little disappointing.

One area I get surprised by is that Custom HTML modules (mod_custom) do not implement cloaking - a little weird but Joomla is huge. I haven't been able to keep up with 1.5.7 or .8 so possibly this has changed.

In any case, I have have several components and areas that I wanted to put in the Joomla cloaking. One area (a custom error page) didn't have a reference to $mainframe so it broke on line 17 in plugins/content/emailcloak.php. So, you may or may not need the first line depending on what you're trying to do.

so, I don't have a solution for mod_custom yet, although now that I think about it, I may be able to create a new view using MVC...
anyway, I'll post that if I get mod_custom tamed.

Here's the code:

global $mainframe;
$plugin =& JPluginHelper::getPlugin('content', 'emailcloak');
$pluginParams = new JParameter( $plugin->params );
require_once (JPATH_SITE.DS.'plugins'.DS.'content'.DS.'emailcloak.php');

$row = new stdClass;
$row->text = WHATEVER STRING/CONTENT NEEDS PROCESSING;

plgContentEmailCloak($row,$pluginParams);

echo $row->text;

As always, YMMV depending on app/component/module/etc and version of Joomla. This block has been reliable for me. Enjoy!

 
Joomla Authenthication Plugin using an XML Web Service PDF Print E-mail
Written by Kirby   
Sunday, 13 July 2008 20:38

I recently had to authenticate against an outside server for Registered User content access. This isn't a huge amount of code but hopefully this will help someone save some time.

Read more...
 
MAMP 1.7 - multiple sites and SSL PDF Print E-mail
Written by Kirby   
Friday, 20 June 2008 13:38
MAMP is great. Almost everyone I know who works on a Mac and does development runs MAMP.

That said, getting certain things to work on MAMP seems to be a black art. There are plenty of posts in the forums with the theme of "uh, that didn't work for me...". Just to add to the body of dubious information, I'm posting my MAMP techniques that may or may not work for you.

Before continuing with this, do one thing right now. Backup your httpd.conf. Do it now before you possibly butcher it, kill your MAMP install and try to contact me with your virulent all-caps inspired hatred. Copying it to httpd.bak.conf is good. Copying it to httpd.yearmonthday.conf works too. Just do yourself a favor and back it up.

OK, next. The techniques described in this article are for your development machine. Yeah, I guess you might find a line or two that will help you on a production server. But, the bottom line is that these are quick and dirty techniques to get multiple sites and ssl running on your MAMP install. If you are planning on replacing your production httpd.conf with what's described here, you'd be playing Russian Roulette with your site.
Read more...
 
Creating a plugin for Openads 2.0 PDF Print E-mail
Written by Kirby   
Tuesday, 14 August 2007 13:33

Creating an Openads 2.0 plugin is pretty easy.

Yeah, this isn't exactly the most current technology article ever written. Everyone is jumping over the new Openads 2.3 Beta and I'm writing about the 'soon-to-be-passé' Openads 2.0. Oh well, maybe someone needs a custom reporting plugin for Openads 2.0. If you do you're in luck.
Read more...
 
<< Start < Prev 1 2 Next > End >>

Page 1 of 2
Joomla 1.5 Templates by Joomlashack