I have product with attribute address - where is product places. It is dropdown list. I want this atttribute will be a link on other site page with map and some other info about this address. But when i use html code in editor of attribute options it's not working. At the same time i checked property "Allow HTML Tags on Frontend" - it has "Yes" value. How can i do this?
Here is how my attribute looks like. and it seams to work:
For the attribute settings I just set to Yes Allow HTML Tags on Frontend and Visible on Product View Page on Front-end. The rest is set to No.
Here is how it looks like in the backend when editing a product.
And here is how looks in the frontend. And the link actually works.
I'm using CE-1.7.0.2.
Maybe the version is the problem. You can also try reindexing after you add the attribute.
[EDIT]
It seams that for 1.9 something changed.
See these lines in the attribute controller _filterPostData method:
foreach ($data['option']['value'] as $key => $values) {
$data['option']['value'][$key] = array_map(array($helperCatalog, 'stripTags'), $values);
}
You can view them here also: https://github.com/OpenMage/magento-mirror/blob/magento-1.9/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/AttributeController.php#L167
The filter method looked differently in 1.8 and before: https://github.com/OpenMage/magento-mirror/blob/magento-1.8/app/code/core/Mage/Adminhtml/controllers/Catalog/Product/AttributeController.php#L153. It didn't have the strip tags on the options. Just the label.
I guess you can try to override the Mage_Adminhtml_Catalog_Product_AttributeController::_filterPostData method and make it look like it does in 1.8. But I don't know the risks.
Related
I'm working on a dotnet 6 mvc application using RazorPages, and I'm having a problem with strange routing behavior.
I have a RazorPage /Pages/News.cshtml
This page is accessible using the default route /news
When called without any parameters this page will display an index of news articles.
I also want this page to be able to display a specific news article, via a path like this...
/news/1234-my-news-article
To achieve this, I've added a config like so...
builder.Services.AddRazorPages(options =>
{
options.Conventions.AddPageRoute("/News", "News/{id:regex(^\\d+\\-.*)?}");
});
In my templates, I can then use links like this...
<a asp-page="/News" asp-all-route-data="#(new Dictionary<string, string> { { "id", "1234-my-news-article" } })">My News Article</a>
or
<a asp-page="/News">All Articles</a>
However, once I've navigated to a specific article, the index link doesn't render correctly, and will instead link again to the same article. It appears to be re-using the current routing parameters.
Is there some way to avoid this?
update:
I've found a work-around, if I use this tag instead...
<a asp-page="/News" asp-route-id="">All Articles</a>
then it will link correctly to "/news".
It seems a bit counter-intuitive to have to explicitly set this to blank. I would have assumed it would default to unset, unless explicitly set otherwise.
This is known as ambient route values (https://www.learnrazorpages.com/razor-pages/tag-helpers/anchor-tag-helper#ambient-route-values), where the current route values are automatically added to outbound links which are generated by the anchor tag helper if the destination page is the same as the current page. In older versions of Razor Pages, this was the default behaviour for all pages.
As you have discovered, you can override this by setting the route value to an empty string, or as suggested elsewhere, to use a plain anchor tag for your link.
asp-page tag helper will add id value to the route by default.It is by design.If you don't want to add it,you can try to use href to replace asp-page:
All Articles
After reading a few question/answers here I have managed to work out how to add a Select list to a form and fill it with data, like so:
#Html.DropDownList("S", new SelectList(ViewBag.S, "Id", "Nme"), "-- Sel a S --")
And it works perfectly. However I would like to add some client-side Validation To validate whether the user has selected an option and not left it at the Default.
I'm using the standard jquery stuff that comes with mvc 3, so presumably I have to do something with HTML.ValidationMessage, but what?
And Can't for the life of me work out how.
TIA.
Ok I had a look through how its done in JQuery land and found just by adding an htmlattribute like so:
new {#class='required'}
to my Html.DropDownList statement, and adding validationMessage, fixes the problem for me.
If you are using the jquery validation then you may simply add the css class reuired and have the required validation for the dropdownlist, provided the default value is empty.
First, if a dropdown is required, add the [Required] attribute to your model property.
Then, enable client side validation somewhere at the top of your view:
<% Html.EnableClientValidation() %>
Then add
#Html.ValidationMessage("S", "*")
Above will only work if the 'default' selection has a null or empty value.
Also ensure you've got the correct js files referenced in the script tags at the top of your page
We have a Magento Shop with some products that have custom options as radio buttons. Every non required option has the first button checked by default but not the required ones. How can I make them checked?
I've allready installed the extension Dependent Custom Options (gallery). That gives me the option to set which custom option should be checked by default but that doesn't update the price to the right value.
Thanks for evey help
This solution may not be the best for you, but I had this same problem, and just fixed it.
First I had to use a convoluted method for installing jQuery correctly in Magento. Part of the problem, I believe comes from the Spriptaculous Effects file being outdated with the latest Magento build. So I went to the site www.script.aculo.us and downloaded the latest version. I then pulled out the effects.js file and used it to overwrite the effects.js in:
[Magento]/js/scriptaculous
Then I downloaded jQuery from the jQuery site and made a folder called jquery in:
[Magento]/js/
And dumped the jquery file in there.
Then I opened the file:
[Magento]/app/design/frontend/default/default/layout/page.xml
And found a list of lines that look like this:
<action method="addJs"><script>scriptaculous/effects.js</script></action>
I copied one of these and replaced the path to that of the jquery file like this.
<action method="addJs"><script>jquery/jquery-1.6.1.min.js</script></action>
Now jQuery will be included in all your pages.
Important! You have to run jQuery in noConflict() mode. So this is what the JS looks like that (for me) worked to select the first radio button on any page with custom options.
var $j = jQuery.noConflict();
$j(document).ready(function(){
// auto selects the first input with radio class
$j('.options-list input.radio:first').attr('checked','checked');
});
I saved that file into my jquery folder and linked to it the same way I linked to the jQ library.
Flushed my cache, and voila!
I hope this helps!
You can use jQuery, as Gordon says, but to update the price you need to run opConfig.reloadPrice() function when check. So the code will be something like this:
var $j = jQuery.noConflict();
$j(document).ready(function(){
// auto selects the first input with radio class
$j('.options-list input.radio:first').attr('checked','checked');
opConfig.reloadPrice();
});
There is a javascript function named something like optionsConfig.reloadPrice() which, when called, updates the price according to options. You probably need to have this triggered during the dom:loaded event.
Go to app\code\core\Mage\Catalog\Block\Product\View\Options\Type\select.php
You can find here your custom option title and set if condition with your title.
For example, my custom option title is price:
if($this->htmlEscape($_option->getTitle()=='Price'))
Is there a way to change the template on a specific article only?
Note that it should work without linking the article to any menu.
If you want the template override not to depend on the menu position than the standard joomla way of assigning a different template to a menu will not work. You will need to get your hands dirty and write some custom code. You will need to use the article_id as a trigger for template switch.
I did something like that at work but don't remember now how exactly this is achieved. I will post my code here as soon as I locate it.
EDIT: Found the code :)
You need to edit the file /includes/application.php, specifically the getTemplate() method. At the end of this method, just before:
// Fallback template
if (!file_exists(JPATH_THEMES.DS.$template.DS.'index.php')) {
$template = 'rhuk_milkyway';
}
you can add your condition for applying a custom template, like so:
//CUSTOM TEMPLATE FOR THE ARTICLE 13
if (JRequest::getVar('id')=='13' && JRequest::getVar('option')=='com_content') {
$template = $custom_template_name;
}
This will apply the custom template which name is inside the $custom_template_name to article with id=13. You can also use it to apply a different template to components, like I did with simplecaddy:
//TEMPLATE FOR SIMPLECADDY
if (JRequest::getVar('option')=='com_caddy'){
$template = 'shop';
}
You should really try to stay away from hard coding anything in to the template if it can be avoided. Not sure why you would specify that the article not be linked from a menu. The easiest way to accomplish this without having to write and code is to create a new menu, then add a menu item that links to the article you want to specify the template for. You don't have to put the menu in a module anywhere so it will never show up on the site, but it will show up in the menu assignment in the template manager.
You can do this with single articles, categories, sections, or even components. As long as you have a menu link to associate the template to. I always create an Admin only menu to put links that are needed to run the site, but do not need to be accessed by users.
As Brent said, avoid the temptation to modify core Joomla code! Doing this will likely stop you from doing Joomla upgrades 'cos you know it's going to break the core changes that you made.
Apart from the "hidden menu item" technique (which is useful but can break SEF URLs in some situations), a useful tool is Chameleon. This allows you to select specific articles/categories/sections (plus things like browser type, user group, component, whatever) and use these to trigger a certain template.
Though this is an old post, I thought I'd share my thoughts: You can easily change template on a single article, by implementing the onAfterInitialize() - function in a system plugin. No need to modify the Joomla core.
This works for Joomla 1.5, but should also work in 2.5:
function onAfterInitialise(){
if(true){ // f.ex. test for article ID or whatever
JRequest::setVar('template', 'beez'); // change template
}
}
In joomla 3.x versions, url-parameters are handled differently. The following was tested in joomla 3.4.8:
public function onAfterInitialise()
{
$app=JFactory::getApplication();
if(true){ // f.ex. test for article ID or whatever
$app->input->set('template', 'beez3');
}
}
More on writing plugins for Joomla here
I've been reading a lot about this problem but I get nothing that suggests a way out.
I am working with version 1.3.2.4 and after creating a bundle product, Magento displays it as price as zero, but gives the "current composition" as the correct value.
alt text http://www.balexandre.com/temp/2009-10-13_2158.png
I already tried to refresh the cache, rebuild the catalog index, and nothing works...
Then I went deep and navigated into the price.phtml template under
template/bundle/catalog/product/view/
and tried to invoke the same method that is showing correctly the value, bu that as well, return zero.
I did notice that Magento has this javascript method
bundle.reloadPrice();
right after and if invoked I do get the correct price... I can try, using jQuery (or Prototype as Magento uses by default) change the value, but I was trying to this right...
Any other ideas?
Had the same problem.
price showed as 0.00.
you have to edit your price-attribute -> show in product-listing: yes
for the product page I'm using this as a work around:
executing this jQuery code:
// hide "Price as configured" text
jQuery(".price-as-configured span:first").hide();
// hide the 0,00 price
jQuery(".price-box-bundle").hide();
// hide the 2nd price (not in image)
jQuery(".product-options-bottom .price-box").hide();
will pass this:
alt text http://www.balexandre.com/temp/2009-10-13_2338.png
into this:
alt text http://www.balexandre.com/temp/2009-10-13_2339.png
In the product grid list I'm using this code to hide the price/button and add to wish list links
// GRID
jQuery("#products-grid-table .price-box").hide();
jQuery("#products-grid-table .button").hide();
jQuery("#products-grid-table .add-to-links").hide();
// LIST
jQuery("#products-list .price-box").hide();
jQuery("#products-list .button").hide();
jQuery("#products-list .add-to-links").hide();
and it will pass this
alt text http://www.balexandre.com/temp/2009-10-14_0005.png
into this
alt text http://www.balexandre.com/temp/2009-10-14_0006.png
I hope it helps someone ...
you can use my magento module: https://github.com/head82/KH_ExtendedBundlePrice tested with magento 1.7