Get Blogged by JoKi

"The only frontiers are in your mind"
11 | 03 | 2010
Navigation
Syndication
feed-image RSS 2.0
Most Read Articles
Related Resources
Article Time Line
Visitors
Validation

Valid XHTML 1.0 Transitional
Valid CSS!

Spacer for layout formatting
Modified Ultimate Paypal Donations Module PDF
Development
Wednesday, 17 February 2010 20:00

The article describes some opinions and modifications for a Joomla! extension called Ultimate Paypal Donations Module by JoomlaSpan.

First of all I have to say that using this extension to provide any kind of PayPal donation element on your site is really easy and straight forward. You just install it, setup your parameters and mdoule location and you are done. It could not be better...

Well, it could.

Actually, my main problem with this module is about XHTML 1.0 compliance. Sadly to see that the current version (as of writing this article) does not follow the W3C rules about XHTML 1.0. Luckily, the necessary changes are very simple to realize by modfying one PHP file. Following is the modified version:

<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_donations" />
<input type="hidden" name="business" value="<?php echo $paypal_emailID; ?>" />
<input type="hidden" name="item_name" value="<?php echo $item_name; ?>" />
<?php if ($item_number)
{
echo "<input type=\"hidden\" name=\"item_number\" value=\"" . $item_number . "\" />\r\n";
}
?>
<?php if ($amount)
{
echo "<input type=\"hidden\" name=\"amount\" value=\"" . $amount . "\" />\r\n";
echo "<input type=\"hidden\" name=\"lc\" value=\"" . $location . "\" />\r\n";
}
?>
<input type="hidden" name="no_shipping" value="0" />
<input type="hidden" name="no_note" value="1" />
<input type="hidden" name="currency_code" value="<?php echo $currency_code; ?>" />
<input type="hidden" name="tax" value="0" />
<input type="hidden" name="bn" value="PP-DonationsBF" />
<?php if ($image_choice==1)
{
echo "<input type=\"image\" border=\"0\" src=\"" . $donate_image . "\" name=\"submit\"
alt=\"PayPal - The safer, easier way to pay online!\" />\r\n";
}else{
echo "<input type=\"image\" border=\"0\" src=\"" . $own_donate_image . "\" name=\"submit\"
alt=\"PayPal - The safer, easier way to pay online!\" />\r\n";
}
?>
</form>

Modified version of mod_paypal-j15/tmpl/default.php

Despite the tooltip description about choosing your own PayPal button for this module you do not need to specify the full URL including http:// prefix. As you can see in the PHP code any relative path is working too. For reduced number of DNS lookups you should get your preferred PayPal button on your server and change the module to use your 'own' image.

In my changes above you also see a marked if-statement in the code. Well, in the original code there are two identical statements, I just merged them together for better reading.

Add last but not least, I removed the border attribute from input tags that displays the PayPal image on your site. Style information like border attributes belong to CSS files and should not be part of the HTML code.

 
Modified HP Router PDF
Development
Saturday, 30 January 2010 15:17

While looking for some improvements of Joomla! native SEF engine I found the following extension quite interesting and easy to use: HP Router of Hannes Papenberg. Installation is straight forward and no struggles at all. For best results you might install this extension before starting any kind of search engine optimization for your website.

But after a short time I was confronted with some 'nasty' behaviour in my website that was introduced by this extension. Some articles did not show up properly and ended in an HTTP 404 error message. Well, actually reading the description of HP Router gave me an idea of the problem:

ATTENTION!! There are a few things you have to keep in mind with this plugin:
1. You can't have the same alias for two articles, even though they are in different categories. To be precise, you can't have the same alias for any type of content item. As a rule of thumb: If you can get to the list of this type of content items from the administrator menu, you can't use the same alias on two items in that list.

My 404 problem is directly caused by duplicated aliases... but not the obvious way!

The reason here is that the extension (as of writing this article) does not respect the state of the articles in the Joomla! CMS. And due to migration processing from previous blog databases I had a bunch of duplicated topics but deleted. This refers to state -2 instead of published content that has a state of 1.

To correct this problem it is necessary to modify two PHP files of the original HP Router:

  • hprouter/com_contentrouter.php
  • hprouter/com_contactrouter.php

Almost of the end of each file there are the SQL statements to query the database. After you made a backup of your two files you should change them like so:

$db =& JFactory::getDBO();
if($vars['view'] == 'article')
{
$query = 'SELECT id FROM #__content WHERE state = 1 AND alias = '.$db->Quote($vars['id']);
} elseif($vars['view'] == 'category') {

Modified version of hprouter/com_contentrouter.php

$db =& JFactory::getDBO();
$query = 'SELECT id FROM #__contact_details WHERE state = 1 AND alias = '.$db->Quote($vars['id']);

Modified version of hprouter/com_contactrouter.php

With those modifications the HP Router works as expected and queries only published articles. Currently, I am not using the archive state of articles but in case that you will, just extend those two queries to include the necessary state values.

 
Modified Mod LCA PDF
Development
Saturday, 23 January 2010 16:06

Joomla! content management system (CMS) is great for websites of any type in general. Even using the system as a blog software is quite easy to configure. Instead of the classical Frontpage Layout as default you configure the system to use one of the available Blog Layouts as default page. Then some tweaks according to leading articles, columns, etc. and you are almost done. Almost...

One of the great features that I like with blog application is the ability to display an Archive list of existing articles based on their creation date. Well, Joomla!s own archive functionality works in a similar way but sadly I experienced own mayor drawback: Archived articles are not part of the internal search engine anymore and therefore results are not displayed.

After my usual online research I found a recently added Joomla! extension called Mod LCA of JoniJnm. The description gives the direct motivation / link to other blog applications:

Mod LCA shows articles sorted by year and month, such as wordpress or blogspot

The module itself is really easy to install and works as expected. Almost...

In case that your content is created the usual way, Mod LCA is just fine. But in my special case I did some direct data migrations via SQL statements from my previous blog software and therefore my sequence of itemids differs from the original creation date of an article. It was quite funny to see that an article of June 2006 was listed in December 2009 by Mod LCA. But hey, when does it happen that the ID and the creation date are controversal? Not quite often but it can happen like in case.

Alright, having a look at the source code files of Mod LCA gives a direct glue about how we can improve the situation. At least, it's nothing complicated but the correct order clause of a SQL statement, or? And there we go...

Before any modifications be aware to have a backup at hand. Open the file mod_lca/helper.php with your favourite text editor and change the query statement like so:

$query = 'SELECT a.id, a.title, a.alias, a.catid, a.sectionid, c.alias as calias, '.
$created.
' FROM #__content AS a'.
' LEFT JOIN #__categories AS c ON c.id=a.catid'.
' LEFT JOIN #__sections AS s ON s.id=a.sectionid'.
' WHERE ( a.state = 1 AND s.id > 0 )' .
' AND ( a.publish_up = '.$db->Quote($nullDate).' OR a.publish_up <= '.$db->Quote($now).' )'.
' AND ( a.publish_down = '.$db->Quote($nullDate).' OR a.publish_down >= '.$db->Quote($now).' )'.
' AND s.published = 1'.
' AND c.published = 1'.
' ORDER BY a.created DESC';
$db->setQuery($query);

... some lines down ...

$out[$d[0]][$month][] = '<a href="'.$link.'">'.htmlspecialchars($row->title).'</a>';

Modified code of mod_lca/helper.php

The original code orders the result set by a.id and this might cause problems. With this minor code change articles are queried in the expected order and as a consequence in my case my 'Article Time Line' in the sidebar is properly rendered and displayed.

After running some validation tests according to XHTML 1.0 compliance I did some more modifications to mod_lca. By adding the PHP function htmlspecialchars() to encode the output of the article title you will get properly encoded special characters in your hyperlinks. This modification has to be done in the helper.php file as you can see above.

To create the tree hierarchy of the article list based on year and month, mod_lca needs some CSS and JavaScript instructions. Well, for the JavaScript it is not a problem itself but the CSS styles should not be placed with the <body> tag of the rendered page. To improve this situation it is necessary to tidy some code of mod_lca.

if (!DEFINED("LCA_HEADER")) {
// If cache is enabled, we can't add css neither js files

define("LCA_HEADER", 1);
echo '
(<style> section deleted)
<script type="text/javascript">

Modified code of mod_lca/tmpl/default.php

The key of this solution is to move the style information away from the module and into the template CSS file or if you prefer in its own CSS file. To reduce the number of HTTP requests the styles should be in the template.css file.

/********
mod_LCA
********/
li.lca {
display: block
}
ul.lca {
padding: 0px
}
span.lca {
cursor: pointer
}

Modified CSS code of template.css

The consequence of those slight modifications is that XHTML validation of my site produces roughly 30 errors less than before. Depending on your content this may vary, of course... ;-)

 
Working with 'Parameter objects' instead of parameters PDF
User Rating: / 1
PoorBest 
Development
Wednesday, 04 June 2008 11:53

Yesterday I stumbled over a good article in German language - Arbeiten mit Parameterobjekten - about using a parameter object rather than using parameters to pass information to functions and methods. As you know, I like this concept very much and actually already use it since years in my daily work. See also my other article on this: Kommentar zu 'Parameterobjekte'

Well, Tom uses blogger and because I don't have an account there I post my comments here in own 'blog space'. In his article Tom shows some code to transfer the value of the properties of the parameter object to the value properties of controls on the form. Well, I think that this could be way easier using the ControlSource property of the control directly. On the one hand the value is then bound to the parameter object and any changes are directly 'transferred' and on the other hand the concept saves you lots of code. Just configure the ControlSource of each control in the Property Window on the form and you are done. No extra code in Init or Destroy methods necessary.

Text1.ControlSource = Thisform.oParameters.StartDatum


In case of an error change the value of Thisform.BindControls = .F. and one of your last lines in the form Init method is to set the value to .T.


Sincerely, JoKi

 

 
Private projects added (at least started...) PDF
Development
Wednesday, 19 March 2008 10:43

I couldn't stop...

There were still some tweaks and fine-tunings to do on this blog after I uploaded the new template and CSS files. But for the moment, I'm okay with the current visual outfit of this blog.

After I finished with the re-design of my blog, I wanted to add some more content and so you get it. Have a look at the new Projects section of this web site. There you will get an overview of my pending private projects, like COM Proxy For .Net, AfpWiki and others. For sure, this project list is going to be completed as soon as I will have more time to add content. At the moment I think, it is most interesting to see that the hyperlinks to download my components are available.

So, please stay tuned, there are more things to come during the next couple of days/weeks.

 
« StartPrev12345678910NextEnd »

Page 1 of 11
Spacer for layout formatting
About me
Microsoft Most Valuable Professional 2007 & 2008

Microsoft Certified Professional

Get in contact

Follow Jochen Kirstaetter (JoKi) on Twitter JoKi @ ICQ JoKi @ Skype


Recent books

  • MCTS 70-536 - .NET Framework 2.0 Application Development Foundation
  • Code-Centric: T-SQL Programming with Stored Procedures and Triggers
  • Microsoft .NET Framework-Programmierung in C#

Community

deutschsprachige FoxPro User Group

Microsoft Community Leader/Insider Program

International .NET Association

O'Reilly Verlag
Sponsoring
If you like the information on these pages, your support is highly appreciated.
Thank you very much!