How to add a custom product template in NopCommerce plugin - nopcommerce

I have created a plugin but it needs a customised product template and I cant get that to work. Could someone please help me understand what I have done wrong?
So far I have:
gone to https://example.com/Admin/Template/List and added a new product template
1a. set the view path to "myCustomPlugin.Views.Product.ProductTemplateCustom.Simple"
gone to https://example.com/Admin/Product/Edit/46 and set that product with the new product template
in my plugin code I have created the template in: myCustomPlugin\Views\Product\ProductTemplateCustom.Simple.cshtml
loaded the product page
when I load the product page I get:
InvalidOperationException: InvalidOperationException: The view 'ProductTemplateCustom.Simple' was not found. The following locations were searched: /Themes/DefaultClean/Views/Product/ProductTemplateCustom.Simple.cshtml /Themes/DefaultClean/Views/Shared/ProductTemplateCustom.Simple.cshtml /Views/Product/ProductTemplateCustom.Simple.cshtml /Views/Shared/ProductTemplateCustom.Simple.cshtml /Pages/Shared/ProductTemplateCustom.Simple.cshtml
I have checked Nop.Web\Plugins\myCustomPlugin\Views\Product and ProductTemplateCustom.Simple.cshtml has been copied over.
I have looked RouteProvider.cs expecting some routing configuration needing to be added to my plugin but I can't see anything
Their documentation says I have to add a new product template to Views\Product so I have done that but it exists in my plugin path and I can't work out how to get NopCommerce to look in that location

Sounds like what you're looking for is IViewLocationExpander. In simple words, this interface allows you to add custom view locations, so you can override the default view from your plugin.
You can find an implementation in Presentation\Nop.Web.Framework\Themes\ThemeableViewLocationExpander.cs
The straightforward way is to provide the full path of the view. However, I prefer using the ViewLocationExpander, it feels more orderly and neat.

Related

Is it possible to create custom entities (entries if you take up the strapi vocabulary) in wordpress?

Edit : the thing I was looking for is called Custom Post Type in the WordPress World
Disclaimer: it is my first steps with WordPress and I realize I do not have the right vocabulary to make a proper google search, so please excuse me if this answer has been already asked many times ...
I'm working on a website that use an old preexisting WordPress as headless CMS.
On this new website, I need to display some "job offers"
On the preexisting WordPress, those job offers are just HTML blocks embedded in a page. So I can't get only those without having the embedded page HTML and CSS
If I could have created a custom REST API to get those "job offers", I would have said that those resources would look like this :
{
title : string,
description: string
}
My first idea would be to create a WordPress custom end point, but I do not know if it is possible to create custom entities (entries (?) If I take up the vocabulary of strapi)
Is this something that can be done?
I've tried :
basic google search
reading the strapi and wordpress documentation
I expect to be referred to a solution or to know what to search
The thing you're looking for are Custom post types if that can help a plugin called ACF can help with the custom fields.

How to add new setting fields to an existing setting page in Wordpress

For a new Wordpress plugin development, I would like to add few custom fields in the exiting setting page of COD.
The examples I have found so far, most of them are creating a new setting page and adding setting fields there.
However I want to use existing COD setting page and add few more fields on the same setting page. How to achieve that ?
Edit:
Please note that I am trying to achieve that by writing a Wordpress plugin. I understand that it requires to use various Wordpress functions like register_setting(), setting_fields(), add_setting_section() etc. But the sequence they should be called is confusing. It is helpful if a sample example is provided.
There are some important links that describe how to add new menu-page/submenu-page/options etc :
https://codex.wordpress.org/Administration_Menus
https://codex.wordpress.org/Creating_Options_Pages

Show data on a specified template in wordpress

I am using one plugin known as Wp store Locator which is not based on custom post type.So that plugin gives one list of store as output and it has in built template for it.I have modified that plugin in a such way that on click of More Details it should take me to detail page of that particular clicked store.
I have built link like this localhost/wordpress/?wpsl-id=3.
So my question is that how can I show only on particular store? I have built one template in that plugin but I don't have any idea how can I use that.
Any help from Wp Store Locator user would be highly appericiated.

Drupal: How to override Advanced Forum topic list for one specific forum term

I'm using Drupal 7, and have the Advanced Forum module installed.
However, I want to show some Ubercart products in one section of the forum, called the Marketplace to make them more visible, and since users will be able to add their own products.
However, obviously in this section I want to show the forum topic list differently, including the price and other such fields.
Is there an easy way that I'd be able to do this, perhaps using Views? I'm really at a loss for what to do.
You should be able to just create a new View with a page display that displays things like you want them and then set the URL for the view to be the URL that is currently being used for the forum listing you want to override, so that the links to it still work without any additional work.
First of all, you should override the page template for one specific term by creating a new page like so:
page__forum_TERMID
To go more into details about what you need to show in this custom page, you may need to install the Devel & Theme Developer modules.
With Theme developer you will be able to inspect your Drupal output on various parts of the page in order to find out either which preprocess function or which template it originates from.
With Devel you will be able to output some of the variables you may need to act upon in order to generate your custom layout.
I would advise you to look at the implementation of the [Advanced Forum More Styles](http://drupal.org/project/advanced_forum_more_styles) in order to see how you could create your own Advanced Forum Style, which basically means a folder where you can store the various custom templates that will override the Advanced Forum templates.
Recently, I did something similar to what you're looking to achieve, I created a custom module to hold the various preprocess functions and that module contained a styles folder which was declared like so:
function YOURMODULENAME_ctools_plugin_directory($module, $plugin) {
if ($module == 'advanced_forum') {
return 'styles';
}
}
If you look at the styles in the AF module, you will see that they only override a few templates, so you may have to find the template you're looking for in the base style such as the "Naked" style.

Drupal 6: Drupal Themer gives same candidate name for different type of content types

I'm a drupal newbie...
I have different type of contents like News, Events, etc. and their content is different. News detail page has title-content text-date. but Events detail page has title-date-content text-location-speaker-etc. So I need different layout page for these different types. So, I enabled Drupal Themer to get a candidate name. for events page, it gave me page-node.tpl.php and it gives same for News page as well :( how can I separate these pages? I expected sth like page-event-node.tpl , but no... :/ Drupal Themer also give unique candidate name for event page like page-node-18.tpl.php but it doesnt mean anything since I can not create a general layout for all events by this node name. :(
Appreciate helps so much!! Thanks a lot!!!
While using different node.tpl.php files as suggested by monkeyninja (+1) would be the 'normal' way, you could add the functionality you want by adding page template suggestions based on node type yourself, in a preprocess_page function within a custom module/theme:
function yourModuleOrTheme_preprocess_page(&$variables) {
// If this is a node page, add a page template suggestion based on node type
if (isset($variables['node'])) {
// Build the suggestion name ('.tpl.php' suffix will be added by the theming system)
$suggestion = 'page-type-' . $variables['node']->type;
// Add to end of suggestion array, thus keeping the fallback to other suggestions,
// if this specific version is not implemented by the theme
$variables['template_files'][] = $suggestion;
}
}
With this in place, you should be able to add e.g. a 'page-type-event.tpl.php' file, which should be used for all event node pages.
(NOTE: You'll need to trigger a rebuild of the theme registry after adding that function to get it recognized by the system)
I'm not familiar with Drupal Themer, but a slightly different approach would be to work with the node templates to style the content and use something like the excellent Context module (and possibly Panels module) to change the layout of any additional information on the page (eg the blocks).
To theme the different content types using node templates, just create templates based on node.tpl.php in the form node-content_type.tpl.php. So you'd have a template for your events nodes called node-events.tpl.php.
You could then define a context using the Context module that reacted when a page of the events content type was displayed and select which regions/blocks you wanted displayed.

Resources