Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

How to set up div tags within xml? 
 
sherrie
Moderator
 
Avatar
Total Posts:  1655
Joined:  2007-12-14
Waterloo, ON
 

I need to be able to add a small bit of javascript and html to my custom shipping module so that I can show/hide the various options within my module (in the backend only), but am not seeing which file this needs to be included in.  Does anyone have any ideas?

 
Magento Community Magento Community
Magento Community
Magento Community
 
sherrie
Moderator
 
Avatar
Total Posts:  1655
Joined:  2007-12-14
Waterloo, ON
 

The file used to set the div class for the title bar of the method is in app/code/core/Mage/Adminhtml/Blck/System/Config/Form/Fieldset.php and looks like this:

protected function _getHeaderHtml($element)
    
{
        $default 
= !$this->getRequest()->getParam('website') && !$this->getRequest()->getParam('store');

        
$html '<div  class="entry-edit-head collapseable" ><a id="'.$element->getHtmlId().'-head" href="#" onclick="Fieldset.toggleCollapse(\''.$element->getHtmlId().'\', \''.$this->getUrl('*/*/state').'\'); return false;">'.$element->getLegend().'</a></div>';
        $html.= '<input id="'.$element->getHtmlId().'-state" name="config_state['.$element->getId().']" type="hidden" value="'.(int)$this->_getCollapseState($element).'">';
        $html.= '<fieldset class="config collapseable" id="'.$element->getHtmlId().'">';
        $html.= '<legend>'.$element->getLegend().'</legend>';

        if ($element->getComment()) {
            $html .= '<div class="comment">'.$element->getComment().'</div>';
        }
        // field label column
        $html.= '<table cellspacing="0" class="form-list"><colgroup class="label"/><colgroup class="value"/>';
        if (!$default) {
            $html.= '<colgroup class="default"/>';
        }
        $html.= '<tbody>';

        return $html;
    }

I can’t seem to figure out how the xml file decides what to declare should follow that code, though.

<config>
  <
sections>
    <
carriers>
      <
groups>
        <
multiflat translate="label" module="shipping">
          <
label>Pickup at Event Multiple Flatrates (Powered by Minerva)</label>
          <
frontend_type>text</frontend_type>
          <
sort_order>1</sort_order>
          <
show_in_default>1</show_in_default>
          <
show_in_website>1</show_in_website>
          <
show_in_store>1</show_in_store>
          <
fields>
            <
active translate="label">
              <
label>Enabled</label>
              <
frontend_type>select</frontend_type>
              <
source_model>adminhtml/system_config_source_yesno</source_model>
              <
sort_order>1</sort_order>
              <
show_in_default>1</show_in_default>
              <
show_in_website>1</show_in_website>
              <
show_in_store>1</show_in_store>
            </
active>
 
Magento Community Magento Community
Magento Community
Magento Community
 
sherrie
Moderator
 
Avatar
Total Posts:  1655
Joined:  2007-12-14
Waterloo, ON
 

Ok, I searched the web for how to embed html in xml as this is really what I need to do and read that I need to do this:

<?xml version="1.0"?>
<xsl:value-of select="showhide1" disable-output-escaping="yes"/>

and this:

<name1 translate="label">
              <
label>Event Method 1 >> </label>
              <
frontend_type>text</frontend_type>
              <
showhide1><![CDATA[ <a href="#" onclick="showhide('div1');">show/hide me</a]]></showhide1>
              <
sort_order>3</sort_order>
              <
show_in_default>1</show_in_default>
              <
show_in_website>1</show_in_website>
              <
show_in_store>1</show_in_store>
            </
name1>

But then it gives me this error:

Warningsimplexml_load_string() [function.simplexml-load-string]: namespace error : Namespace prefix xsl on value-of is not defined  in /lib/Varien/Simplexml/Config.php on line 494

Anyone know how to properly embed html in xml in a way that will work in Magento?

 
Magento Community Magento Community
Magento Community
Magento Community
 
sherrie
Moderator
 
Avatar
Total Posts:  1655
Joined:  2007-12-14
Waterloo, ON
 

Well, I figured out part of my problem, but I still need to find a way to set a namespace so I can wrap the show/hide around 3 different xml blocks in that file.

Does anyone know how I can wrap the following:

<name1 translate="label">
              <
label>Event Method 1 >> <![CDATA[ <a href="#" onclick="showhide('div1');">show/hide me</a]]></label>
              <
frontend_type>text</frontend_type>
              <
sort_order>3</sort_order>
              <
show_in_default>1</show_in_default>
              <
show_in_website>1</show_in_website>
              <
show_in_store>1</show_in_store>
            </
name1
            <
price1 translate="label">
              <
label• Price (0.00)</label>
              <
frontend_type>text</frontend_type>
              <
sort_order>5</sort_order>
              <
show_in_default>1</show_in_default>
              <
show_in_website>1</show_in_website>
              <
show_in_store>1</show_in_store>
            </
price1>
            <
details1 translate="label">
              <
label>• Details</label>
              <
frontend_type>textarea</frontend_type>
              <
sort_order>6</sort_order>
              <
show_in_default>1</show_in_default>
              <
show_in_website>1</show_in_website>
              <
show_in_store>1</show_in_store>
            </
details1>

in something that indicates Method 1 so that I can declare a div for the whole method?

Interesting to note ... the CDATA tag seems to only work if I include it within the <label></label> field.  If I use it here

<price1 translate="label">
              <
label><![CDATA[ <div id="div1"]]• Price (0.00)<![CDATA[ </div]]></label>
              <
frontend_type>text</frontend_type>
              <
sort_order>5</sort_order>
              <
show_in_default>1</show_in_default>
              <
show_in_website>1</show_in_website>
              <
show_in_store>1</show_in_store>
            </
price1>
It actually hides and shows the • Price (0.00).
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top