I am using magento 1.7. i have tried to change wrapper of cms content but still i cannot get how i can change wrapper of cms_page.
<block type="page/html_wrapper" name="cms.wrapper" translate="label">
<label>CMS Content Wrapper</label>
<action method="setElementClass"><value>std</value></action>
<block type="cms/page" name="cms_page"/>
</block>
and html output is
<div class="std">
CMS Page content
</div>
but i want to output like this
<section class="std">
CMS Page Content
</section>
Please give me any solution
You can try following code for change div to section
<block type="page/html_wrapper" name="cms.wrapper" translate="label">
<label>CMS Content Wrapper</label>
<action method="setElementClass"><value>std</value></action>
<action method="setAttribute"><param1>html_tag_name</param1><param2>section</param2></action>
<block type="cms/page" name="cms_page"/>
</block>
this will change div to section because html_wrapper class get tag name from a function getElementTagName in app\code\core\Mage\Core\Block\Abstract\Wrapper.php
/**
* Wrapper element tag name getter
* #return string
*/
public function getElementTagName()
{
$tagName = $this->_getData('html_tag_name');
return $tagName ? $tagName : 'div';
}
so by calling setAttribute we change/set value of html_tag_name
Related
We have a Magento 2 site running Amasty Special Promotions, the "offer label" is showing on the product pages as expected however, it's not showing on the category pages at all. How could this be added, I came across this code in the Amasty extension:
In catalog_product_view.xml
<referenceContainer name="product.info.media">
<block before="-" class="Amasty\BannersLite\Block\Banner" name="amasty.banners.lite.label" template="label.phtml">
<action method="setPosition">
<argument name="position" xsi:type="string">2</argument>
</action>
</block>
</referenceContainer>
In label.phtml:
<?php foreach ($block->getBanners() as $banner) : ?>
<?php if ($block->isEnableBannerPosition() && $img = $block->getImage($banner)) : ?>
<img class="am-banners-lite-label"
alt="<?= $block->escapeHtml($block->getAlt($banner)) ?>"
src="<?= $block->escapeUrl($img) ?>">
<?php endif;?>
<?php endforeach; ?>
"catalog_product_view" fie is layout file for product page.
if you want to display on category page add file in your theme design folder "catalog_category_view.xml" :
<referenceContainer name="content">
<block before="-" class="Amasty\BannersLite\Block\Banner"
name="amasty.banners.lite.label" template="label.phtml">
<action method="setPosition">
<argument name="position" xsi:type="string">2</argument>
</action>
</block>
</referenceContainer>
I'm creating a Flexible Content Element.
In my template configuration flux form I have a field, in an object, in a section. In my locallang.xlf, I can label my object and section, but I haven't been able to label my field successfully.
My template configuration looks like:
<f:section name="Configuration">
<flux:form id="element">
<flux:form.section name="settings.mysection">
<flux:form.object name="myobject">
<flux:field.input name="myfield" />
</flux:form.object>
</flux:form.section>
</flux:form>
</f:section>
The relevant part of my locallang.xlf looks like:
<trans-unit id="flux.element.sections.settings.mysection">
<source>This works</source>
</trans-unit>
<trans-unit id="flux.element.objects.myobject">
<source>This also works</source>
</trans-unit>
<trans-unit id="flux.element.fields.myfield">
<source>This doesn't work</source>
</trans-unit>
What should the id attribute be to label 'myfield'?
In your AdditionalConfiguration.php, add the following:
$TYPO3_CONF_VARS['BE']['lang']['debug'] = true;
Now you will see the full language label paths in the backend:
flux.element.objects.myobject.myfield
It seems this was changed for TYPO3 8.7 https://forge.typo3.org/issues/71095 to
$TYPO3_CONF_VARS['BE']['languageDebug'] = true;
i am unable to populate my Struts2 select drop down in my jsp page.
Note: My jsp page loads through json response.
I have a select box inside a form. But i don't t know how to populate it when my jsp page loads.
And in the same page i have a select dropdown in my Struts2 jquery grid,which i am able to populage but i don't know how to populate a drop down for my form which are out side of the grid.
Please help me regarding this issue.
my jsp page
<s:url id="selecturl" action="selectaction"/>
<s:url id="bookediturl" action="bookeditt"/>
<s:url id="bookremoteurl" action="booksetups"/>
<sjg:grid
id="bookgrid"
formIds="form2"
reloadTopics="reloadMyGrid"
caption="List of Cover Details"
dataType="json"
href="%{bookremoteurl}"
pager="true"
gridModel="gridModel"
rowList="50,100,5000"
rowNum="20"
filter="true"
filterOptions="{stringResult :false,searchOnEnter : false,enableClear : true,gridModel : true}"
rownumbers="true"
editurl="%{bookediturl}"
navigator="true"
editinline="true"
navigatorSearch="false"
autowidth="false"
width= "1550"
viewrecords="true"
navigatorRefresh="true"
navigatorDelete="true">
<sjg:gridColumn name="id" index="locationId" title="ID" formatter="integer" sortable="false" key="true"
search="false" editable="true" hidden="true" />
<sjg:gridColumn name="authLastname" index="authLastname" title="AuthorLastname" sortable="true" search="true" editrules="{required: true}"
editable="true" edittype="text" />
<sjg:gridColumn name="subjectId" title="Subject Name" editable="true" sortable="false" align="center" search="false" searchtype="select"
searchoptions="{dataUrl:'%{selecturl}'}" edittype="select" editoptions="{dataUrl:'%{selecturl}'}" />
</sjg:grid>
<div id="myDivBox" style="display:none; width :300px;position: relative;top: -30px;left: 299px;button:0px;">
<s:form action="searchkeywordss" id="form2" theme="simple" cssClass="yform">
<sj:textfield placeholder="Enter keyword to search" cssClass="txtbox" size="42" maxLength="255" name="keywordsearch"/>
<sj:select href="%{selecturl}" name="countryselect" list="%{lstsub}" listKey="id" listValue="subjectName" theme="jquery" cssStyle="margin-top:4px;"/>
<sj:a button="true" id="btnid" cssStyle="position: relative;top: 0px;left: 09px;" onClickTopics="reloadMyGrid">Find</sj:a>
</s:form>
</div>
struts.xml
<action name="booksetups" class="v.esoft.actions.bookdetails.BookdetailsAction" >
<result name="success" type="json"/>
<result name="login" type="redirect"> /index.jsp </result>
</action>
<action name="selectaction" class="v.esoft.actions.bookdetails.SelectAction">
<result name="success">/select.jsp</result>
</action>
You should only use the sj:select like below
<sj:select href="%{selecturl}" name="countryselect" list="subjectList" listKey="id" listValue="subjectName" theme="jquery" cssStyle="margin-top:4px;"/>
where selecturl returns a json response, subjectList is name of list in the json reponse which contains the options
Your selectaction should have a json response, but what you have now is an action returning a jsp so it would not work. If you cannot change it, you should create another action which returns json.
I have two jsp page, say form.jsp and myForm.jsp.
In the first page, form.jsp, there is a radio button group (the form name is "form").
When the user submits this form, some info are retrieved from a db and with these informations the form in myForm.jsp is built (the form name is "myForm").
The problem is that when this second form is submitted, only the errors are displayed but not the form fields created from db values.
For example, I retrieve from database labels and values for two radio buttons (property="prop").
In struts-config.xml, I have:
<form-bean name="myForm" type="org.apache.struts.validator.MyValidatorActionForm">
<form-property name="prop" type="java.lang.Integer"></form-property>
</form-bean>
<action path="/form" input="/jsp/home.jsp" name="form" scope="request" type="myPackage.LoadInfo">
<forward name="Success" path="/jsp/myForm.jsp"/>
<forward name="Failure" path="/jsp/home.jsp" />
</action>
<action path="/myForm" input="/jsp/myForm.jsp" name="myForm" validate="true" scope="request" type="myPackage.MyValidatorAction">
<forward name="Success" path="/jsp/success.jsp"/>
<forward name="Failure" path="/jsp/failure.jsp"/>
</action>
In myForm.jsp:
<html:form action="/myForm">
<div><label>* <bean:message key="myForm.label"/></label>
<c:forEach var="propTypes" items="${props}">
<html:radio property="prop" value="${propTypes.value}">${propTypes.label}
</html:radio>
</c:forEach>
<html:errors property="prop" />
</div>
<div><html:submit><bean:message key="myForm.label2"/></html:submit></div>
</html:form>
In validation.xml:
After the form submit without select any radio button, the error is displayed, but not the radio buttons.
How could I maintain all the request attributes?
I tried to use scope session too, but nothing has changed:
<action path="/myForm" input="/jsp/myForm.jsp" name="myForm" validate="true" scope="session" type="myPackage.MyValidatorAction">
<forward name="Success" path="/jsp/success.jsp"/>
<forward name="Failure" path="/jsp/failure.jsp"/>
</action>
I resolved by using:
request.getSession().setAttribute("props", props);
in the Action LoadInfo called before the display of the form.
In myForm.jsp I use:
request.getSession().getAttribute("props");
Instead in the struts-config.xml, the scope remains request.
Nevertheless, this isn't a good solution, 'cause different browser tabs share the same session.
How could I resolve this issue?
Your form fields in your jsp page should have corresponding properties in your ActionForm class.
So if your jsp has a the following radio button
<html:radio name="myForm" property="name">
You need a corresponding property in your action form as follows and make sure you have the getters and setters:
public class MyClass{
private String name;
public String getName()
{
return name;
}
public void setName(String name){
this.name = name;
}
If you set it up this way, the user entered values should still be there when your page refreshes.
I'm loading my Zend_Form from an XML file :
<form>
<elements>
<role>
<type>MyProject_Form_Element_Select_Roles</type>
<options>
<label>Role:</label>
<value></value>
</options>
</role>
<valid>
<type>submit</type>
<options>
<label>Valid</label>
</options>
</valid>
</elements>
</form>
Of course the XML below doesn't work since Zend doesn't know how to load my custom field (which is just an extension of Zend_Form_Element_Select), but the line below doesn't work, if anyone can help :
<form>
<elementPrefixPath>
<prefix>MyProject_Form_Element_Select</prefix>
<path>MyProject/Form/Element/Select</path>
<type>element</type>
</elementPrefixPath>
...
I found these config features really cool but finding info or tutorial on them is really tough (I know there's some mapping rule between the Zend_Form objects structure and the expected config file, but I do never found a complete description of it if someone has a link)
Here's the correct form XML description :
<form>
<prefixPath>
<element>
<prefix>MyProject_Form_Element_Select</prefix>
<path>MyProject/Form/Element/Select</path>
</element>
</prefixPath>
<prefixPath>
<element>
<prefix>MyLib_Form_Element_Select</prefix>
<path>MyLib/Form/Element/Select</path>
</element>
</prefixPath>
<elements>
<role>
<type>Roles</type>
<options>
<label>Role:</label>
<value></value>
</options>
</role>
<valid>
<type>submit</type>
<options>
<mycustomoption></mycustomoption>
<label>Valid</label>
</options>
</valid>
</elements>
</form>
The custom options will be send inside the $options argument of the constructor of your Element
class MyProject_Form_Element_Select_Roles extends Zend_Form_Element_Select
{
public function __construct($spec, $options = null) {
//don't forget to call parent !
//$options is a Zend_Config that should have as a member mycustomptions
}
}