Zend Framework and custom Navigation Containers - php

In Zend's Documentation they write about creating Navigation Containers. But they don't explain where I should create them. Does anyone know that?
I'm also wondering if a custom Navigation Container extends or overwrites the navigation.xml file which contains the static links.
(I want to make a custom Navigation Container to add dynamic links from my database)

(I want to make a custom Navigation
Container to add dynamic links from my
database)
Create a controller plugin and initialize the containers there.
If you need, you may restrict it to run only on specific module/controller/action by creating conditions on request parameters or even switch layout if needed.
You may also create navigation container as a model, or create getNavigation() in your existing model and use in anywhere, whenever you need it.
Another solution is to create the navigation container in the view helper on the fly.
Choose the one which works best in your case (eg. depending how do you handle cache).

Related

Symfony website with dynamic content (loaded from the database) in the navigation

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

Pagination in front end Module Joomla

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.

Dynamic Views in ZF2

I am working on my SaaS app which is going to require a Custom ViewModel to be built to populate widgets (left,center,right,footer, etc)
I started off using a BaseController
`class BaseController extends AbstractActionController {`
But since I am going to try to use modules like ZfcUser etc I was wondering can I create a module that builds the ViewModel and if so where/how should I hook into the event to not break forwards/redirects?
My thought is build the larger view model without interfering with normal controller behaviors. The controllers would just pass back their normal array() for the viewmodel and it would be placed it
`<?php echo $this->content; ?>`
Ok clarification on a website you generally have Header, Footer, Content and say Left Nav. So the footer has 3 columns Login Box, Lastest News, and twitter feed, the left nav has Navigation and some ad's
All this really doesnt pertain to the Controller and Action being called so I am trying to find the best place to fetch the ViewModel and how then build and populate with all these external entities (login template,twitter, Nivo Slider) and replace.
Then when the controller returns its array() have it replace the $this->content in the layout
Putting all this in each Action would be huge and would break outside module use.
I suggest to using zf2plugin, but it works with zend forward helper and maybe you don't want this.But there is a closure result mode that you can generate some dynamic content ..
Try it, hope be useful.
you maybe want to create viewhelpers located in modules like a TwitterFeed-Module. the view helper would access a service from the same module.
The TwitterFeed Service would simply request the feed from twitter (and ideally cache it for an hour or so). the viewhelper would just render the data as needed or use a viewscript for rendering or return the raw data to be processed in the layout itsself.

URLs for Joomla Component

I have created a simple basic component in joomla named, careerform so I want to know that what will be its url? Will it be :
index.php/?option=com_careerform
or in sef it will be something like:
index.php/components/careerform
or it will be like this while using .htaccess
/careerform
Is it true or what are joomla default URLs with different settings? Please tell what you know.
thanks for your time.
While what you are asking to do is possible, it would be rather complicated to rename a component. As part of the renaming you would have to update the names of dozens if not hundreds of classes throughout every file of the component. Very likely to run into some bugs because of this.
The far easier prospect is to just avoid these types of urls in your site. Joomla will only fall back to that style of url if a menu item does not exist for the view. Because of that, you can make the url into this:
http://sitename.com/any-component-alias/
To do this, go into the menu manager and create a new menu item. If you don't want this as part of the main menu, you can create a new menu. (I typically have a menu called "Hidden" for menu items that I want aliased but don't actually link to throughout the site from a menu.) When creating the menu item, make sure the type matches the component and view. The alias will then be whatever is entered in the alias box just below the title.
The one issue you may run into with this is that a component may not have a menu type for a particular view. In that case, you you would need to add the necessary metadata.xml file to the view (which again would be much easier than renaming the component!). A good tutorial for that can be found here: http://docs.joomla.org/Adding_view_layout_configuration_parameters.
yes if SEF will be enabled then index.php/component/careerform will be used.
You can create custom URLs by developing a router for your component.
There is very good documentation for it here.

Joomla - configuring basic parameteres for my component in menu manager

Im still relatively new to Joomla component development.
I have a component that manages rsvps to events.
In the administration side you create various events and specify the details of when where and what time the event starts etc. Each event has an eventid.
In the frontend I want to be able to show a specific events details when a menuitem is clicked.
In Joomla administration, my thinking is as follows:
1) Go to Menus->Top Menu
2) Click on [New] to create a new Top Menu Item
3) My component is listed there as MyRSVPComponent
But when I click on it, nothing happens??
All the other default components like search have submenus that you can click on that takes you to a Menu Item page and you are able to configure the Basic Parameters on the right hand side.
I want my component to behave like that as well and I want to be able to pick the event from a list that I want displayed for that menu item. How would I go about doing this?
Please do note that I have not followed the Joomla 1.5 MVC structure for my component.
Can I still make this work, or am I forced to create the project with the MVC structure.
I have my reasons for not wanting to go with MVC for this particular project so please do not just suggest that I go MVC unless that is the ONLY way that I going to achieve what I need to do.
The options you see in the menus are controlled directly by the views in your component. You will need a view for each menu item type you would like to have. You don't have to go MVC but it would certainly make life easier.
I just came across this question with the view to integrate a Symfony project into a Joomal component. Naturally I don't want to use the Joomla MVC for this as well.
I have done some debugging on how to create your menu links:
You need to have the link field set for your component, matching your component folder
You need to have the views folder, matching the "option" field value of your component database entry
As soon as you have this, the menu manager is going to show your views as options
To have specific view sub options, you need to create /com_yourcomponent/views/yourview/layout.xml, copy these from com_content. In there you can also define your menu options.

Categories