简体   繁体   中英

unable to fetch logo in joomla using $this->params->get('logo')

I am creating new theme using joomla. I have uploaded the logo in admin and trying to show the uploaded image using $this->params->get('logo')

But it is not working

In my templateDetails.xml I have added

<config>
        <fields name="params">
            <fieldset name="advanced">
                <field name="logo" type="media" label="TPL_SOFT_FIELD_LOGO_LABEL" description="TPL_SOFT_FIELD_LOGO_DESC" />
                <field name="banner" type="media" label="TPL_SOFT_FIELD_BANNER_IMAGE_LABEL" description="TPL_SOFT_BANNER_IMAGE_DESC" />
            </fieldset>
        </fields>
    </config>

In index.php I have added two lines

echo $this->params->get('logo');
echo $headerImage    = $this->params->get('banner');

These two line returns nothing. Whats wrong with my code.

Update - 1

stdClass Object
(
    [id] => 9
    [home] => 0
    [template] => soft
    [params] => Joomla\Registry\Registry Object
        (
            [data:protected] => stdClass Object
                (
                    [logo] => 
                )

        )

)

To get parameters from the template, you must firstly include this line at the top of your index.php file:

$params = JFactory::getApplication()->getTemplate(true)->params;

otherwise $this will not return anything.

Hope this helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM