Quantcast

Creating a dynamic database based Zend_Navigation item?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Creating a dynamic database based Zend_Navigation item?

Mary Nicole Hicks
Can anyone give me any example on how I could get Zend_Navigation to handle dynamic entries from a database?

My current idea is to extend Zend_Navigation_Page_Mvc and overload most of the methods given by Zend_Navigation_Container.

I have a route of "/articles/:title" and it would be good to have all articles for this available in the navigation. I have too many articles to place them all into the navigation at the same time.

Has anyone solved a similar problem?
Are there any up-and-coming Zend_Navigation_Page_* types that could help solve this?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Creating a dynamic database based Zend_Navigation item?

vince.
Hi,

What's the problem with retreving the enteries from the DB, Assigning them into a multi dimensional array and passing it into the zend_nagivation?

On Fri, May 29, 2009 at 1:20 PM, Mary Nicole Hicks <[hidden email]> wrote:

Can anyone give me any example on how I could get Zend_Navigation to handle
dynamic entries from a database?

My current idea is to extend Zend_Navigation_Page_Mvc and overload most of
the methods given by Zend_Navigation_Container.

I have a route of "/articles/:title" and it would be good to have all
articles for this available in the navigation. I have too many articles to
place them all into the navigation at the same time.

Has anyone solved a similar problem?
Are there any up-and-coming Zend_Navigation_Page_* types that could help
solve this?

--
View this message in context: http://www.nabble.com/Creating-a-dynamic-database-based-Zend_Navigation-item--tp23777517p23777517.html
Sent from the Zend Framework mailing list archive at Nabble.com.




--
Vincent Gabriel.
Lead Developer, Senior Support.
Zend Certified Engineer.
Zend Framework Certified Engineer.
-- http://www.vadimg.co.il/



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Creating a dynamic database based Zend_Navigation item?

Mary Nicole Hicks
vince. wrote
Hi,

What's the problem with retrieving the entries from the DB, Assigning them
into a multi dimensional array and passing it into the zend_nagivation?
The problem is that I can not do this for every navigable page on the site all at once... for every request.

1. Memory due to lots of items.
2. Speed - there comes a point when an array is so large that it is not as fast as an indexed mysql database table.
3. Cache will get out of date quickly.
I have multiple situations like this on the same site and as new pages are being created, moved, renamed quite often, any caching would not be up to date for very long at all.

Creating a navigation tree of every page in the site is not possible for a large site. If the Navigation object is only getting used to show related pages such as parents (breadcrumb) and children (menu). Why should it need to be loaded with tonnes of unrelated pages?



Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Creating a dynamic database based Zend_Navigation item?

Bugzilla from dado@krizevci.info
On Friday 29 May 2009 12:50:09 Mary Nicole Hicks wrote:

> > What's the problem with retrieving the entries from the DB, Assigning
> > them into a multi dimensional array and passing it into the
> > zend_nagivation?
>
> The problem is that I can not do this for every navigable page on the site
> all at once... for every request.
>
> 1. Memory due to lots of items.
> 2. Speed - there comes a point when an array is so large that it is not as
> fast as an indexed mysql database table.
> 3. Cache will get out of date quickly.
> I have multiple situations like this on the same site and as new pages are
> being created, moved, renamed quite often, any caching would not be up to
> date for very long at all.

Offtopic, but I've noticed people don't consider destroying the cache when it
becomes obsolete. For example, lets say you have an article overview and an
article view, lets say there a title, lead and # of comments on overview and a
full article with all it's comments on view.

When displaying the overview, you go for the cache and miss, so we really need
to render this one ourselves. Go through the rendering and remember each
item's ID. When you're done, store the rendered item in cache and tag it with
those IDs (for example, article_XXX), same thing on the view of the article.

When something changes (someone edits the article, someone leaves a comment),
you destroy all cache entries by tag:

$cache->clean(
    Zend_Cache::CLEANING_MODE_MATCHING_TAG,
    array('article_XXX')
);

which will destroy the overview page which holds that article AND the article
view page. With proper situation, usage and the static backend (which is a
great idea IMHO)  [1], an application could have it's cache lifetime set to
eternity and be really fast.

Anyway, we apologize for this interruption and return to our regular
program.... :)

> Creating a navigation tree of every page in the site is not possible for a
> large site. If the Navigation object is only getting used to show related
> pages such as parents (breadcrumb) and children (menu). Why should it need
> to be loaded with tonnes of unrelated pages?

I don't fully understand the problem you're trying to solve.

[1] http://sn.im/j0c9x

--
Dado
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Creating a dynamic database based Zend_Navigation item?

Tim Fountain
In reply to this post by Mary Nicole Hicks

2009/5/29 Mary Nicole Hicks <[hidden email]>

vince. wrote:

> What's the problem with retrieving the entries from the DB, Assigning them
> into a multi dimensional array and passing it into the zend_nagivation?

The problem is that I can not do this for every navigable page on the site
all at once... for every request.

1. Memory due to lots of items.
2. Speed - there comes a point when an array is so large that it is not as
fast as an indexed mysql database table.
3. Cache will get out of date quickly.

I've hit the same problem as you. The Zend_Navigation helpers seem to work perfectly, but they rely on being given a data structure containing the tree of the whole site, which just isn't scalable.

It would be useful to have some input from the author(s) of the component to see if there are any workarounds, or to see if this problem was forseen.

Technically the breadcrumbs helper only needs the current page and its parents, so my only idea is if the Zend_Navigation data structure could be cached in a tree like form matching the URL structure, some clever caching mechanism could just include the bits it needs. But this would be tricky to implement.

--
Tim Fountain
http://tfountain.co.uk/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Creating a dynamic database based Zend_Navigation item?

Mary Nicole Hicks
Tim Fountain wrote
Technically the breadcrumbs helper only needs the current page and its
parents, [...] if the Zend_Navigation data structure could be
cached in a tree like form matching the URL structure, some clever caching
mechanism could just include the bits it needs. But this would be tricky to
implement.
You can extend the Zend_Navigation_Page_MVC and populate all the sub pages from your database, this fills out your tree.

You can Cache the Zend_Navigation object and this saves calculating it again.

The 2 problems with this way is:

Is it wise to have 10,000 page objects for a large site?

Most of the Zend_Navigation view helpers need to know the current page, so it loops over all pages. Looping over 10,000 page objects? crazy.

Now if I go through the uses for it (in documentation):

Breadcrumbs: Mime are usually Module > Controller > Action > Dynamic page
- Will not help me here

Links, used for rendering navigational head links: (Who uses these?)
- Will not help me here

Menu, used for rendering menus: I have to do this in the controller, because only the controller knows the data/item/dynamic info.
- Will not help me here

Sitemap, used for rendering sitemaps: The only time I think you need xml sitemaps is when you have many pages. Zend_Navigation does not work for lots of pages so this is stupid. Also, I have never ever seen a good programmatical way of getting all pages for xml sitemaps. Most methods miss a lot of dynamicly generated webpages (eg Zend_Navigation) or are process intensive (crawl the entire site just to get the urls). The best way I have seen to create xml sitemaps is to simply get all requested urls (ether from log files or add them to the db when they succeed).
- Will not help me here

Just because it is there, does not mean you have to use it.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Creating a dynamic database based Zend_Navigation item?

Jurian Sluiman-4
Op Monday 01 June 2009 13:17:13 schreef Mary Nicole Hicks:
> Tim Fountain wrote:
> > Technically the breadcrumbs helper only needs the current page and its
> > parents, [...] if the Zend_Navigation data structure could be
> > cached in a tree like form matching the URL structure, some clever
> > caching mechanism could just include the bits it needs. But this would be
> > tricky to
> > implement.
>
> You can extend the Zend_Navigation_Page_MVC and populate all the sub pages
> from your database, this fills out your tree.
>
> You can Cache the Zend_Navigation object and this saves calculating it
> again.
>
> The 2 problems with this way is:
>
> Is it wise to have 10,000 page objects for a large site?
>
> Most of the Zend_Navigation view helpers need to know the current page, so
> it loops over all pages. Looping over 10,000 page objects? crazy.
>
> Now if I go through the uses for it (in documentation):
>
> Breadcrumbs: Mime are usually Module > Controller > Action > Dynamic page
> - Will not help me here
>
> Links, used for rendering navigational head links: (Who uses these?)
> - Will not help me here
>
> Menu, used for rendering menus: I have to do this in the controller,
> because only the controller knows the data/item/dynamic info.
> - Will not help me here
>
> Sitemap, used for rendering sitemaps: The only time I think you need xml
> sitemaps is when you have many pages. Zend_Navigation does not work for
> lots of pages so this is stupid. Also, I have never ever seen a good
> programmatical way of getting all pages for xml sitemaps. Most methods miss
> a lot of dynamicly generated webpages (eg Zend_Navigation) or are process
> intensive (crawl the entire site just to get the urls). The best way I have
> seen to create xml sitemaps is to simply get all requested urls (ether from
> log files or add them to the db when they succeed).
> - Will not help me here
>
> Just because it is there, does not mean you have to use it.


Hi all,
In my opinion you should only store the top-level of the dynamic pages in your navigation structure at first sight.


I have a cms where you might have a blog at website.com/something/here/blog and a agenda at website.com/something/else/agenda. Those "overview" pages are stored in the database and are always visible in Navigation (menu, sitemap etc). This object is stored in cache.


When the blog module is in the dispatch loop, it adds some pages to the navigation object (like website.com/something/here/blog/archive). Visiting a blog post (.../blog/1/blog-title-here), some blog articles are added too.
These "special" pages are not visible in sitemap, but when that deep into the website, they are visible in the menu and/or breadcrumbs and/or links.


I think this method is on with the most advantages: store common pages in cache, but still dynamic when required.


Regards, Jurian


--
Jurian Sluiman
Soflomo.com

Loading...