<field
name="published"
type="list"
label="JSTATUS"
description="JFIELD_PUBLISHED_DESC"
class="inputbox"
filter="intval"
size="1"
default="1"
>
<option value="1">
JPUBLISHED</option>
<option value="0">
JUNPUBLISHED</option>
<option value="-2">
JTRASHED</option>
</field>
I've created a Joomla dropdown in my form.xml file of a custom component to choose the published status of the item. I've taken this code unashamedly from the Joomla com_content component (and copied and pasted it into my own form.xml file. However when its rendered in the edit.php file (as shown below) you can see that the item is being set as unpublished. Despite the code above clearly setting the default as 1 which should correspond to published. Any good ideas as to why/how to fix this. I can easily change the drop down back from unpublished to published - and it works fine doing that. But its just annoying and a bug I'd like to fix. Any ideas?
Try to take a look if there is any override through your code, since this was taken by the com_content component, it won't set to default until all the mandatory fields are set, double check if any JS script or PHP function interrupts your field's normal behavior.
Another thought of mine is that maybe there is a problem with the translations, so take a close look to the translation files.
Are you using a table / model approach like com_content does? if so, when the record doesn't exist, its fields will be set to default (as read from database, so int fields will default to 0).
You can either
set the right defaults in the database,
check their values in the model,
change JPUBLISHED to 0 and JUNPUBLISHED to 517
although the latter looks really ugly.
Related
I am using Magento 1.7.0.2 and I want to set a different value for the meta-robots-tag for several products. Therefore I go to Catalog > Article > Meta Information > And select a value from the dropdown "Robots Meta Tag"
Now comes the problem. I just have 4 selectable values in this dropdown, like this:
<select id="seo_meta_robots" name="product[seo_meta_robots]" class=" select">
<option value="0">Don't change</option>
<option value="1">NOINDEX, NOFOLLOW</option>
<option value="2">NOINDEX, FOLLOW</option>
<option value="3" selected="selected">INDEX, NOFOLLOW</option>
</select>
And I'd need a 5th one, labeled "index,follow" - how/where would I need to add that?
Thanks
The easier way would be to copy this file app/code/core/Mage/Adminhtml/Model/System/Config/Source/Design/Robots.php into app/code/local/Mage/Adminhtml/Model/System/Config/Source/Design/Robots.php and add the option there:
public function toOptionArray()
{
return array(
array('value'=>'INDEX,FOLLOW', 'label'=>'INDEX, FOLLOW'),
array('value'=>'NOINDEX,FOLLOW', 'label'=>'NOINDEX, FOLLOW'),
array('value'=>'INDEX,NOFOLLOW', 'label'=>'INDEX, NOFOLLOW'),
array('value'=>'NOINDEX,NOFOLLOW', 'label'=>'NOINDEX, NOFOLLOW'),
array('value'=>'INDEX,FOLLOW', 'label'=>'INDEX, FOLLOW'),
);
}
However, the best practise would be creating a Magento Extension and overriding this model to add the option. Since it's a one line code change it probably doesn't worth the effort though, but bear in mind that you might need to maintain changes on this file if you ever upgrade Magento (it's unlikely that this file will be changed).
I hope it helps!
Following is my code.
<fields name="request">
<fieldset name="request">
<field name="format" type="list" label="COM_CPS_FIELD_FORMAT"
description="COM_CPS_FIELD_FORMAT_DESC" class="small"
default="raw"
>
<option value="">COM_CPS_FORMAT_HTML</option>
<option value="raw">COM_CPS_FORMAT_RAW</option>
</field>
</fieldset>
</fields>
When I save the menu with 2nd option it save the url like this index.php?option=com_cps&view=webservice&format=raw but when I save the menu with first option it does not remove the &format=raw If any one can help me out It would be great.
Default is defined as what to save if nothing is posted. It works like a Joomla input filter in that it changes what is actually saved as opposed to validation which stops the process and never posts. Therefore you cannot save nothing, since it will always be replaced by the default. Therefore if you want to be able to save blank you must not have a default.
What you may be looking for is a preset, which is a preselected value that can be unselected. Presets and defaults are totally different things although on the surface they appear similar.
I've come across a very strange problem relating to 'Alternative Menu Items', the usage is described here:
http://docs.joomla.org/Layout_Overrides_in_Joomla_1.6
The following files are located in: templates/testtemplate/html/com_content/category and these are the steps I took:
These files:
blog.php, blog.xml, blog_children.php, blog_item.php, blog_links.php
Have been changed to:
bloggal.php, bloggal.xml, bloggal_children.php, bloggal_item.php, bloggal_links.php
For file bloggal.xml – I changed this part:
<layout title="COM_CONTENT_CATEGORY_VIEW_BLOG_TITLE"
To:
<layout title="Blog Gallery"
Then added sub headings to bloggal.php and bloggal_item.php so I can see if the child items are in effect.
Now the interesting part is bloggal.php works fine but the child items drawn from bloggal_item.php do not come up.
I've done this test with the same template on multiple Joomla installs, on one of them it seems to work and the rest it does not.
The only thing I can think of is Joomla may have had a regression since the working one was an updated install and the rest are more recent versions.
Any ideas?
Starting Joomla 1.6 you can choose an alternate layout for each category. Including those you have overrides for. No need to select an alternate layout when configuring menu items ;)
Sorry I should've posted this sooner. I figured out the issue, I renamed:
<field name="layout_type"
type="hidden"
default="blog"
/>
To:
<field name="layout_type"
type="hidden"
default="bloggal"
/>
Essentially looking for a model that doesn't exist.
If you did this, do the following to fix it:
Rename default="whatever" back to default="blog"
In your database go to _menu table
Look for your menu item via the title column
Head over to the params and change {"layout_type":"bloggal"... to {"layout_type":"blog"...
What I have:
I have a generic JSP page that is used throughout my application for displaying certain entities. The code that I am interested in goes like this:
<form:form modelAttribute="object"/>
<core:forEach items="${sections}" var="section" varStatus="itemStat">
<core:forEach items="${section.fields}" var="fieldDef">
<form:input path="${fieldDef.fieldName}"/>
</core:forEach>
</core:forEach>
<form:form>
For each section, and for each field in that section, I have an input having the path fieldName, which is what I want to display from each field.
What I want:
I would like instead of the input to be a simple text, like a label.
What I have tried:
I am most certain that I can do it somehow with <form:label> but I can't really make it work. Making a <form:label path="${fieldDef.fieldName}" /> just tells the browser for which field I need the label, but doesn't get the actual value from it.
I have also tried something like ${object.fieldDef.fieldName}, but in order for this to work I would have to first analyze the value of ${fieldDef.fieldName}, which would give me the name of the column, and then do a ${object.column}, but column being a variable I haven't been able to make this work in any way.
Alternative:
An alternative would be to just make the inputs as disabled and remove the border with CSS, but that would be a dirty way and from what I saw it is also tricky for IE different versions. I am sure that I can handle it directly.
I am a little intrigued by the fact that <form:input path="..."> puts into the input what it finds corresponding to that path (same goes for other form elements), but with label it works different.
So, what I want is basically simple, but I haven't managed to find a way. If someone could shed some light, that would be great. Thanks in advance !
You could look into the spring bind tag. I haven't tried using it before but this may work for you, in place of the input tag
<spring:bind path="fieldDef.fieldName">
${status.value}
</spring:bind>
reference: http://static.springsource.org/spring/docs/1.1.5/taglib/tag/BindTag.html
Instead of
<form:input path="${fieldDef.fieldName}"/>
use
<c:out value="${fieldDef.fieldName}"/>
It would display whatever value is there instead of creating a input field. Hope this helps you. Cheers.
Using the spring form tab, one option would be to use
<form:input disabled="true" path="${fieldDef.fieldName}"/>
To further make it not look like an input you could use CSS to style it to your preference.
Some css styles you could use:
background-color:#EEEEEE;border: 0px solid;
Update:
You could look into the spring bind tag. I haven't tried using it before but this may work for you, in place of the input tag
<spring:bind path="fieldDef.fieldName">
${status.value}
</spring:bind>
Since 1.6, I believe, there's a generic way to use 'categories' in your own created components. The default Joomla components also use this. For example: the contacts, newsfeeds and weblinks components all use the generic com_categories functionality to achieve categorized content.
Currently I'm creating a component which also has categories so I'd like to use the generic Joomla category functions to achieve this.
The status: Currently I've got the following:
I've got a submenu 'categories' in my component which links to the generic categories component which some extra options. The options are there so the page will be redirected back to my component on save. This was pretty easy! But..
My problem: Now I'd like to add specific fields to my category, let's say: 'Category Moderator'.
So I've walked to the code of com_categories and in the following file 'administrator\components\com_categories\models\category.php' there is code (line 270) to look for specific component code, like the following:
// Looking first in the component models/forms folder
$path = JPath::clean(JPATH_ADMINISTRATOR."/components/$component/models/forms/$name.xml");
So the components looks (in my case) in the folder: administrator/components/mycomponent/models/forms/category.xml for specific component info.
Now, in the default category.xml of com_categories there's information about the edit screen, like the following:
<field
name="title"
type="text"
label="JGLOBAL_TITLE"
description="JFIELD_TITLE_DESC"
class="inputbox"
size="40"
required="true"/>
So the title of the category is apparantly required..
So I thought I add a line to this file:
<field
name="moderator"
type="text"
label="JGLOBAL_MODERATOR"
description="JFIELD_MODERATOR_DESC"
class="inputbox"
size="40"
required="true"/>
Except that's not enough to add the input..
So I've looked in the administrator/components/com_categories/views/category/edit.php template for hints, how to achieve this. But there's no code to add specific inputs for my component (or I'm wrong ;))..
Fields are added pretty specific like:
<li><?php echo $this->form->getLabel('title'); ?>
<?php echo $this->form->getInput('title'); ?></li>
I've also looked if I can overide the edit.php somehow, but unfortunately I haven't found it..
Short: Anyone knows how to add generic fields to the category edit page?
You can do it by using plugins ( you can take a look at the built-in user profile plugin for an example: /plugins/user/profile ). But if you want to add a "Category Moderator", I think you could achieve it using ACL.