A Free Template From Joomlashack

A Free Template From Joomlashack

Hacks


Controlling the image scaling in your Joomla PDFs PDF Print E-mail
Written by Kirby   
Tuesday, 13 July 2010 16:16

If you've created a pdf in your custom Joomla component, then you might notice that the scaling of those images isn't usually what you expected. Here's some quick code to deal with it.

The issue starts with a hard-coded value in libraries/joomla/document/pdf/pdf.php. Around line 41, you should see var $_image_scale set to 4. This value is then used to set the image scale within the tcpdf object after it's initialized. The problem is that, at least in my case, I don't want my images scaled way down. Maybe this was a way to account for print images that had a resolution of 300dpi. I'm not sure. All I know is that my pdfs all had graphics that once look decent in html, then appeared to be postage stamps.

If your component has a view.pdf.php, you can rectify this. Below is the code I used to "re-inflate" my images.

defined('_JEXEC') or die('Restricted access');

jimport( 'joomla.application.component.view');

/**
* PDF View class for the Somecomponment component
*/
class SomecomponmentViewViewname extends JView {
function display($tpl = null) {

$document = &JFactory::getDocument();

// set document information
$document->setTitle("Some Title");
$document->setName("sometitle");

$document->_engine->imgscale = 1;

$this->assignRef('somevariable',$somevariable);

parent::display($tpl);
}
}

Maybe this code would work in a template override so you could alter the pdf output for com_content. You just need the lines that specifically reference $document.

As usual, hack, alter, ignore, ridicule, praise this code as you see fit.

 
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...).

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

Page 1 of 2
Joomla 1.5 Templates by Joomlashack