fbpx

REPUBLIC DAY SALE

FLAT 40% OFF

Days
Hours
Welcome, Guest
Username: Password: Remember me

TOPIC: XML Parameter to Template

XML Parameter to Template 3 weeks 15 hours ago #27059

  • pkuhlmann
  • pkuhlmann's Avatar
  • Offline
  • Junior Member
  • Posts: 37
  • Thank you received: 2
  • Karma: 0
Hi there,
I have added a new XML Parameter to the theme and add this parameter succesfully to the index.php.
See picture attached
But is there another way to create an override not getting problems with updating the theme.
Or maybe put the new XML parameter to another php file, currently its in the index.php
// Get params
$sidebar_active_color = $this->params->get('sidebar_active_color');
<style type="text/css">
uk-actice li a{color: <?php echo $sidebar_active_color; ?>;}
</style>

The administrator has disabled public write access.

XML Parameter to Template 2 weeks 2 days ago #27206

  • hitesh99raj
  • hitesh99raj's Avatar
  • Offline
  • Administrator
  • Posts: 63
  • Thank you received: 21
  • Karma: 4
Hi,
Thanks for using Astroid, You're doing in right way but it will get issue if you update the template and framework in future. We recommend override xml and php code in proper way to achieve this task. Please follow below steps to override the xml and php.

Step #1. Add new options using xml override

Please create a new file at
YOUR_SITE_PATH/templates/YOUR_ASTROID_TEMPLATE/astroid/options/sidebar.xml
and add below code
<?xml version="1.0" encoding="UTF-8"?>
<form>
    <fields name="params">
        <fieldset icon="fas fa-cogs" label="Sidebar" name="astroid_sidebar_options" addfieldpath="/libraries/astroid/framework/fields" order="3">
            <field type="astroidgroup" name="sidebar" title="Sidebar Options" description="" />
            <field astroidgroup="body" name="sidebar_active_color" type="astroidcolor" large="true" label="Sidebar Active Color" description="">
            </field>
        </fieldset>
    </fields>
</form>

The option will now appear in a separate tab, Please see screenshot for reference.

Step #2. Override sidebar php for add new css

Please copy the
libraries/astroid/framework/frontend/header/sidebar.php
file to
YOUR_SITE_PATH/templates/YOUR_ASTROID_TEMPLATE/html/frontend/header/sidebar.php
and add below code at the end of the file.
<?php
$sidebar_active_color = $params->get('sidebar_active_color', '');
if (!empty($sidebar_active_color)) {
    $document->addStyleDeclaration('uk-actice li a { color:' . $sidebar_active_color . '; }');
}
?>

Please let us know if you need any further help.

Thanks,
Hitesh
The administrator has disabled public write access.
The following user(s) said Thank You: pkuhlmann

XML Parameter to Template 2 weeks 2 days ago #27230

  • pkuhlmann
  • pkuhlmann's Avatar
  • Offline
  • Junior Member
  • Posts: 37
  • Thank you received: 2
  • Karma: 0
Hello,
wow youre great thanks so much.
But I could use the file
...frontend\document\body.php
as well, or not?
The administrator has disabled public write access.

XML Parameter to Template 2 weeks 1 day ago #27233

  • hitesh99raj
  • hitesh99raj's Avatar
  • Offline
  • Administrator
  • Posts: 63
  • Thank you received: 21
  • Karma: 4
Sure, Yes you can use :)

Thanks,
Hitesh
The administrator has disabled public write access.
Moderators: chandandeep
Time to create page: 0.423 seconds