I am trying to build a joomla template and would like to include an image upload option for users to upload custom images for a logo.
Currently I have this structure:
In my templateDetails.xml
:
<config>
<fields name="params">
<fieldset name="basic">
<field name="logofile" type="media"
directory="images"
label = "Logo"
description ="Choose a logo"/>
</fieldset>
</fields>
</config>
Then in my index.php
:
// Getting params from template
$params = JFactory::getApplication()->getTemplate(true)->params;
$app = JFactory::getApplication();
$doc = JFactory::getDocument();
$this->language = $doc->language;
$this->direction = $doc->direction;
// Detecting Active Variables
$option = $app->input->getCmd('option', '');
$view = $app->input->getCmd('view', '');
$layout = $app->input->getCmd('layout', '');
$task = $app->input->getCmd('task', '');
$itemid = $app->input->getCmd('Itemid', '');
$sitename = $app->getCfg('sitename');
$logo = $this->params->get('logo');
Then further down in my body I try to output the $logo
variable but It displays nothing on the screen....
<a href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template; ?>/<?php echo $logo;?>
Anyone know where I might be going wrong?? Much appreciated for any help or advice.
EDIT Made some progess.
when I upload images they are being stored in the default images folder in the joomla directory. I copied the image across to my templates image folder and managed to get it to display using this:
<img src="<?php echo $this->baseurl ?>/templates/<?php echo $this->template; ?>/images/logo2.png"
however it is not dynamic as $logo
is not being used. It does not seem to be assigned any value at all.