I need to add an URL parameter to an existing CMS page. I basically created a categories overview page by creating a CMS page with the URL /artists (in my setup artists are equal to Magento's categories).
Now I need to create a custom/parameter route since I need a category-detail-page.
Example: fooshop.com/artists/artistname
where /artists lists all existing artists (categories) and /artists/artistname just shows one artist (detail) page.
One way to do so would be creating a simple URL rewrite (htaccess) to map all requests to /artists/someparameter to /artists/ but I was wondering if there's a more elegant solution by using Magento's default controller/view structure?
I ended up in writing a custom module that uses a custom controller that extends Mage_Core_Controller_Varien_Router_Abstract.
Related
When creating standard pages we can use single or archive page templates or simply create our own page template creating a new page with the slug for example: photography and actual page: page-photography.php so we can write unique content to each page if we need to.
How can we do the same with custom post types?
So, I have a custom post type called services how can I create custom unique pages for each of my services?
I know I can write the content directly to each service page and pull it from there but this is not what I want. I would like to have full control over each service page.
Can anyone share the proper solution how to handle this, please?
I think, you can create a file with name single-{post-type}-{slug}.php
see more here, Single Post Template Hierarchy
I am trying to add custom sections to the homepage in between product rows, which include products filtered with custom queries not provided by default from CS-Cart.
The usual way of doing this via code (the project is customized to the point that CMS functionality in this case doesn't help) is to do some logic in the proper controller and assign the data to the view.
By researching I know that the index page is handled differently from the other pages meaning that it doesn't follow the controller->view pattern.
How is the index view (homepage) handled on the back-end? Where is the logic for the index page and how do I edit it to customize my homepage?
On backend > homepage CS-Cart follow the same pattern and the files are:
php
app/controllers/backend/index.php
To add your own php code you can add it by adding into file
app/addons/[ADDON_NAME]/controllers/backend/index.post.php
tpl
design/backend/templates/views/index/index.tpl
Please check tpl file because there are already available some hooks
you have to edit config.local file with this code
$config['customer_index'] = '<Your_new_index_path>';
I have 1 custom table (not wp core table) where are specific products imported. I've set up custom wp page where these products are listed, custom filter created etc. In this step so far everything is OK - products are listed and filtering works, pagination works...
But what I want to extend further now - open each product page (like /product-listing-page/product-name-1) when clicking on product names in product list page... How can be this achieved "out of wp_posts" table?
Why I'm not using wp_posts table: web site have static pages and dynamic posts as news and product table is truncated and re-imported once in a day every night! So, can not really use wp_posts page when product list is dynamic and totally truncated before each import...
Any ideas? Maybe anybody already did such stuff?;-)
I don't know if you developed a plugin to handle all the custom table and code you created, but if you didn't, I strongly encourage you to do so.
Because by making your code as a plugin, you have the oportunity to use all the composants of wordpress, like the rewrite rules system, which, I think, could help you to achieve your goal.
I created a plugin some times ago for a website I have the charge and I needed a custom page to be displayed within the website (worpdress) url system, which is what you want to do if I correctly understand your question.
Unfortunately the plugin has evolved since and I didn't keep a backup of that code, but if I remember correctly how I did it back when, here is the rough approach I followed:
I create a plugin which handle :
custom db table(s)
custom php objects
...
AND (this is the intersting part) add rewrite rule to wordpress rewrite rules system as follow:
set rewrite tag (init action) (if needed)
add rewrite rule (init action)
intercept url and parse it to get the params i need in my custom
page (parse_request action)
The following functions may help you with that :
add_rewrite_tag
add_rewrite_rule
And you need to hook in :
init
parse_request
Hope it helps you start.
the solution was quite quick and easy! For my needs it was enough just to register global query var:
function register_new_query_var($vars) {
$vars[] = 'product_id';
return $vars;
add_filter('query_vars', 'register_new_query_var');
and then I changed theme template for page product-listing-page to work for product listing and individual products with using
if(!get_query_var('product_id')). So, if query empty - do listing stuff, if not empty - do individual product stuff!
For me this is quite enough and I do not need even seo friendly urls (because product list changes every day, so - every day will be new products, links, and there will be to much 404 errors)...
and I can use http://example.com/product-listing-page?product_id=1 and page displays with date which is from custom table! ;-)
I would like to create a module that generates a view with predefined settings when a term is created in a particular taxonomy.
I understand that a module can create a view using hook_views_default_views(), but this doesn't allow you to create a view 'on-action', as would be desirable using Rules.
As far as I can see there is no default Rule action that allows creating of views, so is it possible to programmatically create a rule with an action that can create a view?
You may use the Taxonomy Menu Module. It automatically creates menu items based on a vocabulary and integrates nicely with Views as well as Pathauto (for nice urls).
There are two Youtube Videos (here & here) which might help you get along the way.
The Taxonomy Menu Module will create the menu items (linking by default to taxonomy/term/[tid]). The default Taxonomy Term View already listens to these requests and with Pathauto you can create custom aliases (e.g. category/[term_name] for these links which will in turn be used for the rendering of menu items and still work with Views as internally the default urls are used.
i have a category in my store, lets call it Program, this category will only have 1 product, lets call it Program product, so, i've developed a module only to show this category and product, the view is diferent from the others categories, so, if i write in my browser the url
myweb.com/index.php/program.html or myweb.com/index.php/program-product.html i can see the custom categories page or the product view page and i don't want that, i want that if someone write this url he will be redirect to another one, how can i do that, if it is posible
thanks
"Do you want the category to show in the category menu but link to your new URL and not show in the old one?"
"yeah, this is exactly what i want, is this possible??"
Try this; Go to the menu Catalog > URL Rewrite Management and find the entry for your category. Crucially it's target path will look something like "catalog/category/view/id/123" ('catalog' is the module, 'category' is the controller, 'view' is the action and 'id/123' is a parameter).
Follow these URL rewrite instructions to delete the above entry then create a replacement. It's only difference will be the target path, use your module's path along with whichever controller, action and parameters are suitable for this case.
By preserving the ID Path of the old rewrite rule you are ensuring it doesn't get overwritten, although I haven't tested this with rebuilding indexes.
Does the category's enabled setting, and the product's visibility setting affect your module's display? If not use those settings to hide them from the catalog but continue using your module as normal.