I have this problem:
I have a default route that looks like this: .../myapp/index.php/config/configuration/test/product_id/51
As you see, this leads to the ConfigurationController and in there to the testAction function. Thats fine and it should stay this way. What I want to change though is the "config part" of the URL.
So instead of
http://somedomain.de/myapp/index.php/config/configuration/test/product_id/51
I want
http://somedomain.de/myapp/index.php/furniture/configuration/test/product_id/51
to lead to the same location (ConfigurationController and in there to the testAction function). The part that is changed, is not static, its the attribute set name of the product. So instead of furniture it can be computer or something else. I can already get this from the product, So all I need is the rewrite stuff.
Ideas how to do that? THANKS!
In the module's config.xml you can change the frontend/routers/your_router/args/frontName which will allow you to use a different name (like furniture). If its an adminhtml controller, you have to use an adminhtml router but the rest is the same.
You can use a router, just like Magento does for CMS pages (explained in the second part of this article : http://alanstorm.com/magento_dispatch_admin_cms_default_routers)
Related
i am very new of Magento2, I saw in the "page" that this form should be used to call out the newsletter form :
{{block class="Magento\Newsletter\Block\Subscribe"
name="static.newsletter"
template="Magento_Newsletter::subscribe.phtml"}}
But I would like to change the words of this form, or add more words there. I have already tried looking for in the system but didn't find it and I dont know where to change it. Does anyone can help ?
There are 2 approaches for changing words inside that form.
If you want to change this form for everywhere on your Magento system, you can override it inside your theme.
app/design/frontend/[Vendor]/[Theme]/Magento_Newsletter/templates/subscribe.phtml
If you want to change this form to a specific page, you can create your own template and assign it.
I want to apply condition for specific page coming from url. It is neither a category page nor a custom cms page. Url is like localhost/project/index.php/news/blog.html. I want to apply condition for this 'news/blog.html' . News or blog is not a category and not any cms page. Can anybody help me?
It depends on the type of condition, you want to user over there. You can try with the following.
1. Try to put a observer in the relevant controller using the cheat sheet https://www.nicksays.co.uk/magento-events-cheat-sheet-1-5/
2. Directly try to edit model in the module of that page.
3. Try to put some code directly into the file.
Thanks,
Use the following code.
Mage::app()->getRequest()->getControllerName();
It will give controller name to your module. Put consition for this name and write your code. It will work for sure.
I have human friendly urls without index.php. I had to modify .htaccess file for that. Actually I always use Codeigniter like this. My url-s always look like this:
www.example.com/controller/function/parameter
So if I have an extra url parameter, then the url looks like this:
www.example.com/controller/function/parameter?archive=2013
Now what I want to do: If there is 'archive' parameter in the url, than also add that to the url when anchor function creates a link.
We have some different stuff every year (like stylesheets), so I need to make this navigation automatic. Am I thinking in the right direction?
And the answer is "Yes".
I slightly modified the solution from here:
How to extend anchor() function to anchor_admin() in CodeIgniter?
I've created a custom hook, so that I can include my custom module in any .tpl file by a single line: {hook h='calcSubstrate'}.
However, I can't use it in CMS page, at least not by using the admin panel - including smarty code in a CMS page won't render, the code would appear just as it is, as a text: {hook h='calcSubstrate'}.
Alternatively, if that would be easier/faster - how can I choose on which pages my module would appear?
The editor for CMS page won't recognize any Smarty code. To include hooks in chosen articles/pages, I can think of two options:
Include the hook in the template (cms.tpl), and check for the id of the current page to conditionally display the module. The list of the page ids can be made as the module's configuration.
Build a module to add functionality similar to Wordpress's shortcode to the CMS content. I do this with module instead of overriding the CmsController class, hence I have to display the content with {$cms->content|module}. You can look at the simplified code here for inspiration: https://gist.github.com/tungd/cef0ca1ac1063c1ee90b. Of course you can make it more generic like Wordpress, by having only one Smarty modifier do_shortcode that does everything (just like Wordpress's do_shortcode function).
Last time I did this it was because my client want to put slideshows in some CMS pages, and I chose the second approach because it gives a lot of flexibility about when the module is displayed and where it is displayed between the content. For something else, for example Contact Form, or Map, this would be overkill and the first approach is better.
I am currently working on integrating HTML cuts into Magento's template, however, I am just a little stumped on the structure of Magento itself. I want to list all of the categories inside a custom template in the 'navigation/left'.phtml file. The following accepted answer Magento: Display sub-category list seems to do what I need to do, however,I don't feel comfortable in calling a model inside of a view files as in MVC, which the accepted answer has done.
Is there a better way of putting this in another section of Magento, or perhaps a custom block which extends the Block_Catalog_Product_List class would be a better way of retrieving the categories?
Thanks
The simplest way to do it is to create a module with a helper inside it, that returns the data you need. Then in the template file call this:
$data = Mage::helper('myhelper')->getCategoryList();
//do your magic with $data
There is no point in overriding blocks unless there is no other solution.