I want my url to be like this:
mysite.com/categories/roofing
I can achieve this by creating a new navigation group called categories and make roofing a child BUT I do not want a new Navigation group. I want to be able to call a specific function by identifying segment 1 while still having the url include segment 2.
I tried doing it in "Page Types" but it will not allow you to create a multi segment slug.
I have the stream module if that helps.
Many Thanks !!
This is actually really simple and there are a few ways to do it. The simple way would be to create a page with the slug categories (you can redirect this page using routing later if you don't want it to exist), and then create a page with the slug roofing. Finally, in the pages section of the admin, drag roofing under categories as a child.
This can also be done using routing. You would create a routes.php file with the config folder with the following:
$route['categories/(:any)'] = '$1';
Related
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.
How to identify coding having this file at magento .
For example,
Link Mean
how to identify which file its denotes ?
http://localhost/index.php/about-magento-demo-store/ is not a file, it's CMS page content which is actually a row stored in the cms_page table in your database that gets filtered through a template to produce html page content that is pushed to your browser.
Look under the CMS=>Pages menu, you'll find a grid and if you search in the url key column for about-magento-demo-store, you can find the page content there.
Magento's content does not exist as static pages, it is data stored in the database that gets selected, filtered through templates and assembled into HTML that gets final styling from CSS. It only becomes a page, once it is downloaded by the web browser.
1)Url redirects
look at the core_url_rewrite table and find the url that you requested.
if you find it, and target path starts like catalog/category/view/id/5,
that means catalog module, category controller, view action which you can find in
app/code/core/Mage/Catalog/controllers/CategoryController.php the method is viewAction.
2)Cms Pages
it can be a cms page
3)One of modules controller
It is the best way to install a profiler and see which controller handles your request.
How to create a new layout for different task and call that layout inside a condition in joomla component??i have created a new component there i need to create a new default.php and want to call within a condition so pls anyone answer me how to do?
Instead of using default.php, you can create a different layout like 'your_layout.php' inside your tmpl folder of corresponding view. You can use $this->setLayout('your_layout') in order to display this layout based on the required condition.
Hope this is what you are looking for... if not, please clarify.
I'm trying to render a view, defined in a module, in the main site homepage (~/) as it's main content. If the user is not authenticated, i need to show a login/register view instead.
The logged-in view lives in one module (Product Module) and the login/register view lives in another (Account Module). The logged-in view requires a service call to fetch data based on the user's products. I'm currently using standard mvc to render these views and fetch the data they require in their controllers.
Can this be accomplished by treating these views as shape templates? If so, are there any examples of pulling in views to the homepage like this? Or is there a better way of achieving this?
I have tried implmenting IHomePageProvider to return my own homepage ViewResult within the Product module, but without any success.
Cheers.
First, you might want to look into widgets and layers. You could define a layer for authenticaed users, and one for anonymous users, and attach widgets to those layers to achieve what you want. That might be the best way for you to accomplish this. Look in the Orchard docs for examples on how to do this.
I have done a similar thing before using custom controller and a lot of custom logic. Because of my specific requirements widgets and layers would not work for this. All the content on the page needed to change depending on some inputs, and widgets and layers were not going to be well suited for this. What I did was create a custom controller, and a corresponding Route with a high priority (so the Route takes precedence over any others that want to be the home page). I didn't mess with IHomePageProvider at all.
In the controller action I pulled the data necessary, and created the shapes I wanted, and then returned a result like this: return new ShapeResult(this, homePageShape);
homePageShape is constructed like this, right before the return statement:
// Create personalized home page shape:
var homeShape = _orchardServices.New.CustomHome(
SomeShape1: someShape1
, SomeShape2: someShape2
, SomeModel1: someModel1
...
);
This creates a shape called CustomHome, and orchard will automatically look for a template called CustomHome.cshtml in the views folder of your module.
I created several shapes (all the "someShapeX" vars you see above). Mostly they are created from content parts via the BuildDisplay() method. The content parts are queried using IContentManager, and the shapes are created like this (this example is for a slide show shape):
dynamic sliderShape = _contentManager.BuildDisplay(sliderPart, "Detail");
You can put logic in the controller to build the shapes you want depending on whether or not the user is logged in. In CustomHome.cshtml you would render a shape like this:
#Display(Model.SomeShape1)
I'd like to add a new tab to the 'catalog->manage products->product information' page in the admin. Underneath the 'images' tab, I'd like to add a new tab for video, with a simple text input for adding a video url, which I can then grab for the frontend.
Anyone any ideas where the files are that I need to edit? I've been looking for the last couple hours with no joy. I found the list of current options in Mage_Catalog_Model_Resource_Eav_Mysql4_Setup but can't figure out how to add to them...
Seems it gets some from Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs. If I copy one of the tab sections here and change the title to Video, I can get it to display in the tabs on the left. But how do I then add the options for it?
What you are trying to do, from the sounds of it, is to create a custom field and add it to your catalog data. The good news is that you don't need to muck around in the PHP for that.
Head to Catalog -> Attributes -> Manage Attributes and create a new attribute for yourself called "Video URL" (or something to that effect). This will probably be a text field, and you may want to hide it from comparison on the frontend of the site (select "No" for all those boxes at the bottom of the form).
Once you've created an attribute, you will need to add it to an attribute set. If all your products are of one "type", and if you didn't create any other attribute sets, this should be only one step. Head to Catalog -> Attributes -> Manage Attribute Sets and create a "New Group" called "Video" and drag your new video url attribute into it. Save the attribute set and you should now have your new tab.
The only complication from what I read in your post could be positioning it underneath the images tab. Magento adds several tabs statically (the long way, in the PHP) and doesn't generally obey ordering of the tab groups. Consider the time tradeoff.
Hope that helps. Thanks,
Joe
Per your other comments, for the URLs a simple attribute would work but files would tend to be more difficult. To add a custom tab, as you said, you can edit (or in the case of a plugin, override) Mage_Adminhtml_Block_Catalog_Product_Edit_Tabs::_prepareLayout and add your tab. You'll need to add a block or template to display your tab contents.
After that, you'll need to store the data somewhere. Looking in Adminhtml/controllers/ProductController, you should be able to hook into the catalog_product_prepare_save event to get data from $event->getRequest() and push it onto the product or save another entity as necessary.
I'm not sure how well file saving semantics would work on a product, so you may want to do your own data storage in the extension and then provide something like a getVideoForProduct method to retrieve it.
Then the only thing left to do is modify the catalog/product/view.phtml template file to include your thumbs and create a controller in your extension to provide a modal w/ the video (or do it in JS).
I know that's a bit of a general answer, but it's the rough path you would need to take for tabs. Let me know if any specific part of that is unclear.
Thanks,
Joe