For the coming 0.04 release of the Flashfeed extension, I wanted to create a Joomla component that when installed, it also installed files into other folders than just its own com_flashfeed folder. In my project, I wanted to install extra views into the com_content folder. After desperatly searching for solutions, I ended up banging my head against the wall several times. It was not until I read a post at the Joomfish homepage that I got on track.

I finally found the solution yesterday. The way to do it is to use a custom install file in the XML manifest, and then initially install the files in the component folder, but afterward move it with the JFile class:

Creating the XML File

First of all we want to create our component XML manifest file. To test it, I create a simple XML file with just one file in it:

<?xml version="1.0" encoding="utf-8"?>

<install type="component" version="1.5.0">
       
        <name>Flashfeed</name>
        <creationDate>2009 04 01</creationDate>
        <author>Rune Skjoldborg Madsen</author>
        <authorEmail> This e-mail address is being protected from spambots. You need JavaScript enabled to view it </authorEmail>
        <authorUrl>http://www.youcanjoomla.com</authorUrl>
        <copyright>Rune Skjoldborg Madsen</copyright>
        <license>GNU/GPL</license>
        <version>0.02</version>
        <description>Feed XML from Joomla into Flash</description>
 
        <installfile>install.flashfeed.php</installfile>
        <uninstallfile>uninstall.flashfeed.php</uninstallfile>
 
        <!-- Site Main File Copy Section -->
        <files folder="movefiles">
                <filename>com_content/views/article/view.xml.php</filename>
        </files>
 
        <administration>
 
                <!-- Administration Menu Section -->
                <menu link="option=com_flashfeed">Flashfeed</menu>
 
        </administration>
   
</install>

If you're not familiar with the xml manifest, then please refer to the Joomla Docs. What's important is, that in my zip install file, I've added a folder called "movefiles" where all the files I want to install into other folders than my document root are located. For the moment, I have only one file:

<files folder="movefiles">
    <filename>com_content/views/article/view.xml.php</filename>
</files>

Notice the "folder" attribute. This will tell Joomla to copy from "movefiles/com_content/views/article/view.xml.php" in my zip package to "com_flashfeed/com_content/views/article/view.xml.php". This is the place where we want to move the file from in our custom install script (called install.flashfeed.php in the xml.

Moving the file from standard component location

When our custom install script is called, out files are already uploaded. Therefore all we need to do is to move the file to the location we want to. This is the entire install.flashfeed.php file:

<?php
defined( '_JEXEC' ) or die( 'Restricted access' );

jimport( 'joomla.filesystem.file' );

function com_install()
{
    $fileloc = 'com_content/views/article/view.xml.php';

$from = JPATH_ROOT.DS.'components/com_flashfeed/'.$fileloc;
$to = JPATH_ROOT.DS.'components/'.$fileloc;

if(!JFile::move($from, $to))
    {
        echo 'something went wrong';
    }
}

?>

All we're basically telling it is to move the file from the "com_flashfeed" folder to the "com_content" folder.

Tadaaaa!

And there we are. This caused me serious headaches and some desperat posts in the forums, so I hope it will be of some assistance to you.

Comments (2)
Thanks
1 Saturday, 12 September 2009 20:37
Ramsey
Thanks! It helped me a lot.
Thanks
2 Monday, 14 September 2009 14:43
Arthur Yap
Thanks mate!

This helped me to add custom sh404 plugin on the installation of my custom components :)

Cheers!!! :)

Add a comment

Your name:
Your email:
Your website:
Subject:
Comment:

Search

Donate

Please consider making a small donation to the development of the Flashfeed extension, this blog and my other Open Source projects. The products are all free and developed in my spare time when I'm not studying. In other words, help me buy pasta and ketchup.