In Zend Framework 2 I use ZendNavigation for the main navigation and the breadcrumb-navigation. I want the Breadcrumb-Navigation to show on every page, but I do not want every page to appear in the main navigation.
So in other words I want some pages to show ONLY in breadcrumb navigation.
Is there any way to achieve this? Maybe an option that can be set in the navigation-array? Or do I need to create two different navigations and use one as main navigation and the other as breadcrumb?
Edit
It doesn't really make sense to duplicate the 'pages' configuration as you can instruct the view helper to render what you need. So you can use the same navigation container to render different menus (e.g. breadcrumb vs main navigation).
You can do this by either using the provided breadcrumb methods such as setMaxDepth() or setMinDepth(). Alternatively, for more flexibility, use a view partial as I explained bellow.
In each case you are simply filtering down the complete container into the seletion you want to render.
You can use a view partial to render the breadcrumbs.
This method will find the deepest active page and pass an array of pages that leads to the active page to the partial view script.
The example in the attached link uses array_map to render the contents of $this->pages, however you can achieve the same result with a loop.
foreach($this->pages as $page) {
printf('%s', $page->getHref(), $page->getLabel());
}
Keep in mind however you will now need to check the accessibility of the page manually for the current user if you are using the ACL - This can be done using the methods available for MVC or URL pages
Related
The website I'm working on has a navigation menu item called categories which is a drop-down containing some entries from the db (the users can adjust the categories from the admin panel.) The navigation is located in a base.html.twig file which is extended by all other twig files.
Question: What's the best way to get those entries? The only way that comes to my mind is use a call to {{ render(controller(...)) }} which would create a new request, what's a little overkill in my opinion and will slow the page in general down. Is there a better way to do it? Maybe an event which is called on every request and is able to transfer data to the view file?
You have two good options to achieve this :
Use render() in your twig template to call a specific method from a controller (as you said in your message)
Create a twig extension to render your menu, it's very simple : http://symfony.com/doc/current/cookbook/templating/twig_extension.html
In my opinion you should use the first option (a controller), since you only need to render your menu 1 time. Twig extension are better designed to be reused in several templates.
About your performance concern, don't worry, all you need is to cache your menu since it won't change often, and invalid the cache when the menu is updated in your backoffice.
Regards
I've searching trough google for a way of adding pagination into a module, but i could only find information about adding it into components like here:
How to add pagination for component front end (Joomla 2.5)
Is it posible to implement this same principles to make a pagination for a module?, or a different approach is needed?
I think this is not the correct way of doing to try to implement pagination in a joomla module. Normally, only component are made to be able to use standard Joomla pagination, because it uses itself models and view controller...
The example we see on the link you propose is using pagination from the view controller (view.html.php), witch extend JViewLegacy (witch is an alias for JView). Pagination is natively supported by it.
I imagine you need to show many items pages on a module, but maybe reload the page for it is not the best option. You can perhaps try to load more items, and to use a JS script to do pagination (even a slider can do it nicely), or simply to add a link to the whole section of the associated component.
The menu class documentation - and the provided example - do not seem to show any way for me to build a navigation menu with more than 1 level of navigation.
What do I do if I want to build an 'app-style' menu - like 'File' or 'Edit' - which will include sub-menus? Is there a way to create this automagically with Agile Toolkit, or is this something that would have to be coded by hand with html templates, css files, etc.?
there is no such component by default - however, View "plug'n'play" also works for Menu's
here is one example of real life 2-level submenu:
http://www.gradpool.ie/gradmatcher/graduate/company.html?id=38
idea there is that menu is constructed, and drop downs which fall out are yet another menu objects inserted into menu items.
add-on for this purpose has been created, read here:
http://www.ambienttech.lv/blog/2012-07-06/tree_view_in_agile_toolkit.html
I would suggest to use your own CSS along with Menu_Light, which is designed to get out of your way as much as possible.
https://github.com/romaninsh/atk4-sitesample/blob/day1/templates/Symisun_01/shared.html
https://github.com/romaninsh/atk4-sitesample/blob/day1/lib/Application.php
The only thing it does is adding a class to your menu template, the rest you control over the HTML.
As a result you'll get something like this: http://example.agiletoolkit.org/examples/website/index.symisun
Be sure to use page tag around page names account/register.
I want to have a view displayed as a menu either in primarylinks or secondarylinks.
I searched and looked up all modules with no luck.
should I build this functionality manually ==> build a module?
thanks in advance
Primary and secondary links (in fact, all menus) are rendered as unordered lists of links using a theme function like theme_links(). You can get pretty close to the same functionality by using the HTML List style within a view.
You can't duplicate it exactly because Drupal's menu system requires static menu items: it doesn't handle wildcards like the results of a query.
That is, Drupal's menu system is cached, and is only rebuilt upon request (e.g. by adding a menu item manually, clearing the cache, etc.) A view, on the other hand, is a wrapper to a query: every time you access the view, unless it too is cached, it runs a query to get the latest results.
So, if you were to inject a view into a menu, it'd only be the results at the time of first request, and any subsequent changes would require rebuilding the menu.
The solution I suggested will let you keep the functionality of the view, theme it to look like a menu, and avoid the caveats of the menu system.
I had created my own little lightweight framework for small projects, and now switched to Kohana.
But I wonder what's the way to go to achieve navigation hierarchies.
Example: I have a menu like this:
Home | Products | Support | Contact
In my old framework, when the user clicked on "Products", my framework knew which navigation layer this is and then my view attached an "_active" suffix to the css class of that menu item, so it's highlighted. The same for all parent navigation elements.
How are you setting up your site in Kohana to achieve something like this?
I thought about making one big layout view that contains the menu bar. There, I would have to implement all the logic to figure out which menu item has to be highlighted as active. Is there any clever mechanism for this, or would I just have to figure out from the current url somehow in a bunch of if-statements, if an url segment matches the menu item?
You can use the uri::segment() method to get the current page, and then determine what your suffix should be based on that.
Example:
# Example Url: http://www.example.com/index.php/article/paris/hilton/
echo $this->uri->segment(3); // Returns 'hilton'
From there it's just a matter of checking the returned value against each one of your navigation links - when it maches, add your suffix.