Building a menu the MVC way in PHP - php

Hello I'm building my own PHP MVC framework. Not with the intention of using it. But I'm trying to learn PHP5 OO and the MVC design pattern.
I've read a lot of tutorials and got the basics working but now I'm stuck since things are getting more complicated.
My framework uses the following URL structure: /controller/action. Optionally followed by an inifinite number of variables, e.g. /product/view/1.
So far I got two separate controllers: page and product. I wan't to include them both in a single menu. I'm trying to establish the following menu structure. The corrosponding URL is between brackets.
Our company (/page/view/2)
Werkwijze (/page/view/3)
Staff (/page/view/4)
Our products (/product/index)
Bread (/product/category/1)
Banket (/product/category/2)
Cake (/product/category/3)
Contact (/page/view/5)
So basically I got a main menu and a sub menu. There are a few requirements I defined for the menu class:
The current item should have a different CSS class in the menu.
If the current item has a parent than that should have a different CSS class as well.
The menu should be expandable using all kinds of content a URL's.
And for bonus points: when I select a product from the Bread category. Let's say /product/view/1; then I'd like the 'Our products' and 'Bread' menu items to be highlighted as well.
I've got a copy of my 'framework' running here: http://www.eriknijland.nl/stackoverflow/. The content is in Dutch though and the menu is just static HTML.
The source code is available for download as well in the folder:
/stackoverflow/source/framework.zip
/stackoverflow/source/framework.sql
Any other comments on my code are welcome as well :P.

All the code to build that should be in the view layer of the application. Of course, the framework should provide methods to know wich module and action are active, but the behavior of the menu should be implemented in the application and not in the framework.
Another option would be to design the framework so that it provides some helpers to build menus automatically. In this case, everything should be implemented within the view layer of the framework.

Related

basic joomla extension development confusion

I want to develop a joomla 2.5 porfolio extension.
So I need something in the backend to enter a couple of details.
On my frontpage I want to have listed the six latest projects and there will be a page in the frontend where all projects are listed.
I'm new to this whole joomla thing. At the moment I'm reading through the joomla docs and tutorials.
I'm a little bit confused because I'm not really sure which type of extension do I need.
Can all this be done with a single component or a module or do I have to mix both?
Because what I've understood so far a component can just be displayed as a independent page.
And a module has to be included in a page. Like {lastSixProjects}?
Can some please enlighten me a little bit?
If you want to create a page with portofolio only, you may create a component without a module...
If you want to put your portofolio in eg.: articles pages, search page, in a sidebar etc (like a image slideshow plugin) you must create a module (with a component assigned to it)
Please read this: http://docs.joomla.org/Extension_types_%28general_definitions%29 .
I undestrand that you want to put your portofolio in your front page... in this chase you MUST create a module.
Little explanation:
A module is an extension (similary to boxes, or widgets) that are arranged arround a component (in this chase com_content - on your FrontPage). Eg: Ads Module, Search Box Module etc.
A component is a super complex extension (similary to mini applications). It has an administration part and front-end part. All Joomla! pages loads a component. Eg: Content component, Search component etc.
I hope this will help you.
You want a component. Please read this: http://docs.joomla.org/Extension_types_%28general_definitions%29
Agree on 2 previous answers, you need a component with at least one table to store your projects. Then you need to link to a menu a view of the elements on a table. You should be able to make it work in 15 minutes with this component creator for Joomla http://www.component-creator.com/

Can I create a menu with sub-menus in Agile Toolkit?

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.

developing module with drupal

I have a website which is up and running on drupal. Its product based website. I developed by creating my own tables and writing php code using php filters. I never used module concepts. Since the site is running well, so i am thinking to move to module concept. so wanted some help here, like how to do it.. i have gone through module development concepts also.
requirement.
1. Admin should be able to create new products like Mobile, Camera.
2. He should be able to define product properties and properties for which user will rate on.
3. Admin/ second admin should be able to create new sub products under products like mobile - nokia 8850 , nokia 9980 where he enters details of product properties also.
4. A listing page for all the sun products under main product. and from listing page we go to to main sub product page where user rates the product.
My confusion : should i create a new table or drupal takes care of all the requirements. and how do i start with it.
update : clear picture of requirement
ex :
1. 1st i add a product "MOBILES"
2. Then i add properties for this main product.
3. Then i start adding sub products under MOBILES i.e nokia 1100, samsumg 2200 and etc.
while adding sub products, in this page it gives me a text box for all the propeties i defined while creating the main product MOBILES . So is this possible using CCK.
You're right to consider using modules and following the "Drupal way". Use CCK + Views and Drupal will take care of the table maintenance and querying for you.
As already mentioned, you will need to get familiar with the CCK module. This module will allow you to create new "content types", which in your example would be the different product types and their attributes. Here is a good overview video on CCK. With CCK you can define new content types and Drupal will create the basic content creation forms for you and hide spare you from all the database details when you're working with it.
The Views module is essentially a query builder and will allow you to create views of your content. There are all sorts of related modules that can help you render your data as charts, grids, lists, slideshows, tables, etc.
There is a slight learning curve but once you get past it you'll be able to build new things pretty quick.
Update: Just another thought, if you are really needing to create some kind of classification system you should look at Taxonomies.
It sounds like you could do all of this with modules, without needing to do any php coding at all. Check out (if you haven't already) cck, views, and fivestar.
In response to your update, sounds like CCK and Node Hierarchy should do everything you need.

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.

Using Symfony, sfDoctrineGuardPlugin plugin, How can i customise sf_content? Using partials?

I am using symfony 1.4.8 with sfDoctrineGuardPlugin for my backend.
My question is how can i customise sfDoctrineGuardPlugin's default content? For example, how can i do something on the page between filter and table (on the left hand site)? Or, how can i customize table (http://goo.gl/ZmRey)?
I cannot find any solution for using partials on backend. Is there any way to use partials/components/slots on backend?
I hope you understand my question and tell me a way.
Thanks for your answer(s),
Erman
Partials, components and slots are no different on the back-end to the front-end - your "backend" is just another Symfony application. From the screenshot you gave, it looks like you're looking to customise the admin generator theme.
The quickest way to get started with this is to look in your cache/appname/ folder and see the automatically-generated modules here, with all the template files, partial files and so on. You can then create an empty module in your application, and override select parts of the theme with whatever you want to change. See this part of the Symfony docs for a full list of partials etc, and how to go about overriding them in more detail.
In the specific case of sfDoctrineGuardPlugin-module pages, these can be overrided in the same way as normal modules - simply create eg an sfGuardAuth module and override the selected parts of the module you want to.
If you want to go further and create your own admin generator theme, this is a bit more advanced. Here I will shamelessly promote a blog post I wrote last year ;-) John Cleveley's presentation also provides some great tips.

Categories