i've recently started to use marteenba's sitemap provider, because i couldn't solve a route problem with the other sitemap i had. It's way better than my previous one. My question is: how can i create different breadcrumb trails from pages that go to a single main page? Consider the idea below:
Sitemap Structure
<mvcSiteMapNode title="Home" controller="Home" action="Index" changeFrequency="Always" updatePriority="Normal">
<mvcSiteMapNode title="Clients Search" controller="ClientBussiness" action="ClientSearch" description="Clients Search">
<mvcSiteMapNode title="Contract Analysis" controller="Contract" action="Index"/>
</mvcSiteMapNode>
<mvcSiteMapNode title="Advanced Search" controller="ClientBussiness" action="AdvancedSearch" description="Clients Advanced Search">
<mvcSiteMapNode title="Contract Analysis" controller="Contract" action="Index"/>
</mvcSiteMapNode>
<mvcSiteMapNode title="Another Search" controller="ClientBussiness" action="AnotherSearch" description="Clients Another Search">
<mvcSiteMapNode title="Contract Analysis" controller="Contract" action="Index"/>
</mvcSiteMapNode>
</mvcSiteMapNode>
On the example above, my breadcrumb trail always shows the node Clients Search instead of any other. I don't know if should create different routes for each kind of search (i did this on my last sitemap, but unfortunately iis6 didn't like it).
I appreciate your help.
EDIT
searching on forums i found a similar question. So, consider the structure below:
Home >> Search >> Contracts
Home >> Another Search >> Contracts
Home >> Advanced Search >> Contracts
Home >> Web Service Search >> Extra fields >> Contracts
Well it seems that all i needed to do was to add some dynamic nodes attributes on my controllers. You can read how to do it here. Using the example above, here's how it's done:
[MvcSiteMapNodeAttribute(Title = "Search", Key = "search", ParentKey = "ContractSearch", Route = "SearchRoute")]
[MvcSiteMapNodeAttribute(Title = "AdvancedSearch", Key = "ContractAdvSearch", ParentKey = "AdvSearch", Route = "AdvSearchRoute")]
[MvcSiteMapNodeAttribute(Title = "AnotherSearch", Key = "ContractAnotherSearch", ParentKey = "AnotherSearch", Route = "AnotherSearchRoute")]
public ActionResult ContractIndex()
{
//Things to do...
}
On the example above, each kind of search will be properly defined on the breadcrumb trail.
Keep in mind that you have to define different routes for each kind of "search" you want to use. So, if you want to have 3 nodes pointing to the same url, each node must have it's own route and it's key, defined on MvcSiteMapNodeAttribute.
Related
In short what is happening is, when I try to access a route, Laravel shows a 404 error, with a short description "Page not Found, No query results for model [App\Models\Product] teste ".
Inside of my model I have the method "teste" which invokes a route.
public function teste($crud = false)
{
return '<a class="btn btn-xs btn-default" href="product/teste" data-toggle="tooltip" title="Just a demo custom button."><i class="fa fa-search"></i> Add Item</a>';
}
button image in the datatable line
Adding a button inside of ProductCrudController
$this->crud->addButton('top', 'bteste', 'model_function', 'teste', 'beginning');
Inside of custom.php I have tried already:
CRUD::resource('product/teste', 'ProductCrudController#teste');
Route::get('product/teste', 'ProductCrudController#teste');
Inside of my Controller I have my method named teste
public function teste(){
return view('vendor/backpack/crud/teste');
}
And finally inside of this path I have my view "which is pretty simple" and only retues a simple hello.
What is the purpose
I need to build a form which allows the user to add "a component" for the product once that the product is always customized. This means, a combination of components makes up a new product.
What I need is: Add a new button in the product line which when clicked gonna redirect the user to add all components which makes up this product. Same idea of an order which contain items.
I could not find by myself the possible options to fit my need.
Is that possible to be done by backpack? If so is there any example to be followed?
Thanks
I have installed the Ajax Search Lite plugin for my wordpress site and have edited the Header.php file to place the code.
This is the code that I am currently using to display it:
<body>
<!-- Header -->
<section>
<div class="navbar navbar-inverse navbar-static-top">
<div class="container">
<?php echo do_shortcode('[wpdreams_ajaxsearchlite'); ?>
This is how it displays on my site currently and in the same screenshot points out where I would like place it:
Ajax Search Lite Placement
Is anyone able to help me achieve this? Is there a better way to implement the search function where I want rather than in the Header.php file?
Any assistance is really appreciated.
approach # 1 : add the short code, in the menu or theme files where your menu is getting rendered. (or)
approach # 2: You don't need a walker in this case. A filter called wp_nav_menu_items is available. It allows you to edit the list items of a menu. Just append your own list item with search field.
add_filter( 'wp_nav_menu_items', 'add_search_to_nav', 10, 2 );
function add_search_to_nav( $items, $args )
{
$items .= '<li>SEARCH'.do_shortcode('[wpdreams_ajaxsearchlite').'</li>';
return $items;
}
Ref: https://wordpress.stackexchange.com/questions/52286/using-a-menu-walker-add-a-custom-item-at-the-end-of-the-menus-items
I am using MVC3, C#, Razor, mvcSiteMapProvider V4.
I am using "Mvc.sitemap"
<mvcSiteMapNode title="Reports" controller="Report" action="Index" preservedRouteParameters="ClientId" route="Report">
<mvcSiteMapNode key="Report_Section" title="Sections" controller="Section" action="FilterByReport" preservedRouteParameters="ClientId,ReportId" route="Report_Section">
<mvcSiteMapNode key="Background" title="Background" controller="Wizard" action="Index" preservedRouteParameters="ClientId,ReportID,SectionID,SectionName" route="Background"/>
The "Global.asax" custom routes look like:
routes.MapRoute("Report", "Report/{ClientId}", new { controller = "Report", action = "Index", ClientId = UrlParameter.Optional });
routes.MapRoute("Report_Section", "Report/{ClientId}/Section/{ReportId}", new { controller = "Section", action = "FilterByReport", ReportId = UrlParameter.Optional });
routes.MapRoute("Background", "Report/{ReportID}/SectionID/{SectionID}/SectionName/{SectionName}", new { controller = "Wizard", action = "Index", ReportID = UrlParameter.Optional, SectionID = UrlParameter.Optional, SectionName = UrlParameter.Optional });
The "Report" and "Report_Section" routes work fine. However when I go into the "Background" route I lose all of my route structure, for the "Report_Section" and "Report" routes, in the mvcSiteMap BreadCrumb URL. Instead I get a GUID ie:
http://localhost/7ebe9bb9-a663-43fd-9fb1-865866be12b9
I believe this might be the XML Node Key that is autogenerated. However it prodocues a 404 when clicked.
I should get something like:
Reports
http://localhost/Report/10
Sections
http://localhost/Report/10/Section/100
Any ideas what could be causing this?
Thanks.
You will get a Guid for the URL if the URL resolver cannot find a match. Throwing an exception in this case was causing other issues (see why does URL resolver throw an exception).
However, I can't tell you exactly why it is not matching without seeing more of your configuration. A clue is that we are using UrlHelper.RouteUrl(string, RouteValueDictionary) to resolve the URL. You can try calling it explicitly with your route values and route name. Also, see the source code for other clues.
One thing I noticed that looks off is that you are preserving the ClientID route parameter for Background when it is not even used in that route. Keep in mind that preserving route parameters only copies them from the current HTTP request and your other nodes will appear to forget them.
PreserveRouteParameters is typically used for CRUD operations where you make data editing pages. If you want it to appear to "remember" the user's navigation path, then you need to add 1 node per unique route value combination to your sitemap.
If the above doesn't help, please create a small demo project that exhibits the problem and either upload it to GitHub or else zip it and make it available for download, then open a new issue at GitHub with the link to the demo.
What is the best way to link to categories and products from static blocks.
I ask because sometimes we will update URL-keys for categories, etc, which will break links in static blocks to given categories and products.
Is there a better way to link using ids etc so the links will be active regardless of seo-friendly urls?
Currently, I use links such as:
<a href="store.com/generators/generators.html?"generator_package=6>link</a>
When the urls for the categories change the above link would be broken.
How about this? Let me know the result, maybe we can handle other ways.
+++ EDIT - New Code Sample +++
First create a static block which is this block should reference a phtml file that you can put your logic into this file.
{{block type="catalog/navigation" name="catalog.category" template="catalog/category/ListCategory.phtml"}}
Create ListCategory.phtml in the /app/design/frontend/[YOUR_THEME]/template/catalog/category/ directory.
<?php
// get current category id
$curCategory = $this->getCurrentCategory()->getId();
// instance of Mage_Catalog_Model_Category
$category = Mage::getModel(catalog/category)->load((int)$curCategory);
// child category id array
$childCategories = $category->getChildren();
?>
I have an MVC3 C#.Net project. When I initially load my Web site, I want to route to an Index page and have the navigation tabs at the top of the screen be disabled until a selection is made. Once a selection is made, the site routes to a details page. I would then like to enable the navigation menu itmes. How can I do this? Pass a ViewBag around? Not sure
I think the problem is that Index page doesn't follow a layout of the rest of the website, therefore index page shouldn't use a master layout.
On your index page:
#{
ViewBag.Title = "Index page";
// Null or a custom layout
Layout = null;
}
<p>Your content below</p>
If you want to render a menu on some condition, then store menu in a partial view model, e.g. SiteNavigation.cshtml
You can then render this view based on some condition. E.g.
#if(true){
#{ Html.RenderPartial("SiteNavigation"); }
}
I found an answer to my question. #CodeRush's answer is cool, which I will use in another scenario. But I like the implementation, below, for my prticular situation. In the Object1Controller Index get Action, I added the below code:
ViewBag.Hidden = "hidden";
Then in the Details get Action, which is the Action called when a link is clicked on the Index view, I added this code:
ViewBag.Hidden = "visible";
Then in the _Layout.cshtml I added this code:
<li style="visibility: #ViewBag.Hidden">#Html.ActionLink("About", "About", "Home")</li>
Which renders as:
<li style="visibility: hidden">About</li>
or
<li style="visibility: visible">About</li>
In the other Controllers, I don't need to set the ViewBag.Hidden property since the default for the visibility attribute is "visible". For the other Controllers, the ViewSource shows:
<li style="visibility: ">About</li>
Which renders as visible