<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Paco Hope &#187; Joomla</title>
	<atom:link href="http://paco.to/category/joomla/feed" rel="self" type="application/rss+xml" />
	<link>http://paco.to</link>
	<description>My Random Musings and Rants</description>
	<lastBuildDate>Mon, 06 Feb 2012 13:11:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>New JoomlaCode Project</title>
		<link>http://paco.to/2007/new-joomlacode-project</link>
		<comments>http://paco.to/2007/new-joomlacode-project#comments</comments>
		<pubDate>Mon, 31 Dec 2007 01:05:43 +0000</pubDate>
		<dc:creator>paco</dc:creator>
				<category><![CDATA[Joomla]]></category>
		<category><![CDATA[Web Stuff]]></category>

		<guid isPermaLink="false">http://paco.to/?p=210</guid>
		<description><![CDATA[My script for importing a bunch of pages into Joomla has matured some. It's now the bulkimport project at JoomlaCode. Anyone using the old version of my script should probably watch the new project from now on.]]></description>
			<content:encoded><![CDATA[<p>My script for importing a bunch of pages into <a href="http://www.joomla.org/" target="_blank">Joomla</a> has matured some. It's now <a href="http://joomlacode.org/gf/project/bulkimport/" title="Bulk Import">the bulkimport project</a> at JoomlaCode. Anyone using <a href="/?p=191">the old version of my script</a> should probably watch the new project from now on.</p>
]]></content:encoded>
			<wfw:commentRss>http://paco.to/2007/new-joomlacode-project/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bulk Import HTML into Joomla</title>
		<link>http://paco.to/2007/bulk-import-html-into-joomla</link>
		<comments>http://paco.to/2007/bulk-import-html-into-joomla#comments</comments>
		<pubDate>Sat, 07 Jul 2007 04:00:39 +0000</pubDate>
		<dc:creator>paco</dc:creator>
				<category><![CDATA[Fun Stuff]]></category>
		<category><![CDATA[Joomla]]></category>
		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://paco.to/?p=191</guid>
		<description><![CDATA[I have a site I'm migrating from straight HTML to Joomla, and I have a bunch of HTML files I want to load into it. I wrote a perl script that automates all this. It reads the HTML file to determine the title of the page, it looks at the file's modification date to determine [...]]]></description>
			<content:encoded><![CDATA[<p>I have a site I'm migrating from straight HTML to Joomla, and I have a bunch of HTML files I want to load into it. I wrote a perl script that automates all this. It reads the HTML file to determine the title of the page, it looks at the file's modification date to determine the "publication date" for Joomla, and then it makes a MySQL database connection and executes the query.<span id="more-191"></span>This is a quick script I hacked together in about an hour. It probably works, but it is not for the faint of heart. If you barely understand Joomla, and you've never looked at perl before, and you're working from a Windows PC, go elsewhere. This will be a lot of trouble for you and I won't help you. If you're using a Mac or Linux, or you're comfortable running Perl on Windows, this is pretty straightforward.</p>
<h2>Preparation</h2>
<ol>
<li><a href="/wp-content/uploads/2007/07/UploadToJoomla.pl">Download the script</a>.</li>
<li>Make sure you have the Perl prerequisites:
<ul>
<li>HTML::Parser</li>
<li>DBI</li>
<li>DBD::mysql</li>
</ul>
</li>
<li>You must edit the script itself and change about ten things. That sounds like a lot, but they're all obvious and straightforward. You edit these 10 lines:</li>
</ol>
<blockquote>
<pre>$db::user      = "dbuser";
$db::passwd    = "dbpass";
$db::database  = "joomla";
$db::hostname  = "localhost";
$db::port      = "3306";
$db::tablename = "jos_content";
$j::state    = 1;
$j::section  = 1;
$j::category = 1;
$j::creator  = 62;</pre>
</blockquote>
<p>The database stuff is obvious (you have to tell it what database server to connect to, what the database name is, the table name, and the credentials to use. The "state" is whether you want it published or not. I don't know what the value needs to be to be "not published." I'm going to guess 0. The category and section numbers should be easy to figure out from the category and section lists in your Joomla administrator interface. Finally, you need to figure out what your creator ID is. 62 is always admin. I don't know how to figure out the right number for your particular user. Inspecting your MySQL database and looking at a post that is similar is a good way to find out these values.</p>
<h2>Create a directory</h2>
<p>This script takes exactly one <strong>directory</strong> name (not file names) as its <em>one and only </em>argument. Put each file that you want uploaded into the directory. If you want some files going into one category and other files going into another category, create several directories. Run the script on one directory, then edit it to change the category, and run it on the other directory. See? It's crude, but effective.</p>
<h2>Run the script</h2>
<p>The script is called UploadToJoomla.pl. Invoke it (when you're ready, by typing</p>
<p><tt>perl UploadToJoomla.pl <strong>directory</strong></tt></p>
<p>(where directory is the location of the files to upload).</p>
<h2>Limitations and Things to Know</h2>
<ul>
<li>It takes the file's modification date (the date that you see when you run ls or DIR) and makes that the creation date for the article. I.e., in Joomla, that's the date that the article will appear to have been written. If you do as I suggest above, and you make <em>copies</em> of files in different directories, you'll create a bunch of new files whose modification date is right now. Moving files from place to place is the only safe way to preserve their modification dates. That's mv on FreeBSD / UNIX / Linux, REN on DOS / Windows, and dragging and dropping stuff around on MacOS and Windows.</li>
<li>For those of you on a UNIX-like system, it does not handle symbolic links. They're ignored.</li>
<li>It does not go into subdirectories. That was a conscious choice on my part. It would be quite easy to modify the script to check if the entry in a directory is another directory, and then decend into it by calling processDir(). That's left as an exercise for the reader.</li>
<li>The script looks for the &lt;title&gt; tag to determine the article title. If it doesn't find that tag, then it just assigns a single word "Article" as the title and summary.</li>
<li>The article Title and Summary will be the same. All of the file's content goes into the Intro Text. There will be no additional text.</li>
<li>The entire content of the HTML file, even bits that Joomla doesn't want (e.g., &lt;body&gt; tags, &lt;head&gt; tags, etc.) will get sucked into the database. As far as I can tell, Joomla handles this very gracefully. None of those things come out when the article is displayed on the site.</li>
</ul>
<h2>Closing Thoughts</h2>
<p>I don't do a lot of programming for the public domain. Mainly I hack stuff until it works for me, then I move along. I hope this is helpful for people, but understand that it's not production-quality software. If you have trouble, you can <a href="mailto:paco@paco.to">email me,</a> but I might not be able to help you. Please realize that I literally never use Windows. So if you email with a problem about running it on Windows, I'll be more lost than you are.</p>
<p>The code is released under the Perl Artistic License, which pretty much means you can do lots of stuff with it as long as you keep it all free (as in beer) and open.</p>
]]></content:encoded>
			<wfw:commentRss>http://paco.to/2007/bulk-import-html-into-joomla/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Random Images In a Joomla Article</title>
		<link>http://paco.to/2007/random-images-in-a-joomla-article</link>
		<comments>http://paco.to/2007/random-images-in-a-joomla-article#comments</comments>
		<pubDate>Mon, 12 Mar 2007 02:18:10 +0000</pubDate>
		<dc:creator>paco</dc:creator>
				<category><![CDATA[Fun Stuff]]></category>
		<category><![CDATA[Joomla]]></category>
		<category><![CDATA[Technical]]></category>

		<guid isPermaLink="false">http://paco.to/?p=157</guid>
		<description><![CDATA[I wanted to have random images appear in the body of a content item in Joomla. I used kl_PHP and some template tricks to do it.]]></description>
			<content:encoded><![CDATA[<p>There's a <em>random images</em> module for <a href="http://www.joomla.org/">Joomla</a> that I use in some places. However, i wanted to have random images appear in the body of one specific content item, and not anywhere else. I pulled together a few technologies, including:</p>
<ul>
<li>kl_PHP</li>
<li>Blue Lights Template</li>
<li>Random Image Module</li>
</ul>
<p>Together, they let me do it. Read on for the full scoop.<br />
<span id="more-157"></span></p>
<h1>1. Download and Install kl_PHP</h1>
<p>The <tt>kl_PHP</tt> module allows you to insert PHP code in an article and then Joomla will actually execute it. It is hard to find online, as the original site appears to be down or broken or something. I found <a href="http://www.joomlafrance.org/telecharger/fileinfo/kl_PHP.html">kl_PHP</a> at <a href="http://www.joomlafrance.org/">JoomlaFrance</a>. I installed it as a mambot, and it worked fine. Nothing special there.</p>
<h1>2. Upload some Images</h1>
<p>To get this to work, you'll need to upload some photos and know where you put them. I recommend the following steps.</p>
<ol>
<li>Make all your images the same size. If you let the browser resize them or if they're all different sizes, they'll look bad. Because of the nature of how I was using them, I chose to make them all 250 pixels wide. I let the height vary a little, but not too much.</li>
<li>Create a folder for just these images. Go to Media Manager and create a folder.</li>
<li>Upload your resized images to the special folder you created.</li>
</ol>
<p>Your folder will be rooted in /images on the web server. So, if you called your folder "random," then the path you need to know is "/images/random."</p>
<h1>3. Configure a Random Images Module</h1>
<p>Go to the <em>Site Modules</em> control in the administrator console, and find "Random Image." Change this how you like. You'll want to set things like:</p>
<ul>
<li>"Show Title" should be off</li>
<li>The folder for the images has to be set to the one you created above (e.g., "/images/random")</li>
<li>Set the size of the images, if you want. If you don't, Joomla will pick a pretty small size.</li>
<li>Set "Published" to Yes</li>
</ul>
<p>Note: Use small images! If you don't resize your images, people will waste time and bandwidth downloading big images. For example, if you got them from your digital camera, and they're 6 megapixel images (e.g., around 6 megabytes in size), use some software to shrink them down. If you put a 6 meg photo on your web site, and then tell Joomla to display it as 360x240, people still download 6 megabytes of photo. Their web browser just struggles with it and has to convert it to a smaller size after they've downloaded the whole thing. Your site will be faster and your users will be happier if you resize your images small.<br />
<!--more--></p>
<h1>4. Examine your Template</h1>
<p>I use a template called <a href="http://www.joomlaos.de/Downloads/Joomla_und_Mambo_Templates/Blue_Lights.html">Blue Lights</a>. You can do this with any template, but what you do may be a little different than what I did. What you're looking for is a <em>module position</em> that is not used by your template. In my case, I discovered that Blue Lights does not use the <strong>inset</strong> position, so I used that.</p>
<p>An easy way to figure out if a module position is used is to publish your "Random Image" module (that you created in Step 3) in various positions. If it doesn't show up at all, then your template doesn't use that position. For example, virtually all templates use "left" and "right." But some may not use "cpanel" or "toolbar" or "header". Find one that's unused. It doesn't matter what it's called. It just matters that your template has no use for it.</p>
<h1>5. Use kl_PHP</h1>
<p>Advanced users have probably been skimming. "Get to the good part already!" they say. This is the trick. In your content item, put some kl_PHP like this:</p>
<pre>{kl_php}

mosLoadModules( 'inset' );

{/kl_php}</pre>
<p>Since you're publishing the "Random Image" module to the 'inset' position, this PHP code will generate the correct HTML output for a random image.</p>
]]></content:encoded>
			<wfw:commentRss>http://paco.to/2007/random-images-in-a-joomla-article/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

