Welcome Guest, Not a member yet? Register   Sign In
Performance of multiple view calls
#1

[eluser]louis w[/eluser]
Wondering is there is performance considerations with making multiple view calls when building a site.

I am building a menu and wanted each row to be a view call. But it could be >10 calls just for 1 menu. Would this slow things down as opposed to calling a function for each row and hard coding html in it.
#2

[eluser]xwero[/eluser]
Why not a partial view with a loop in? Wouldn't that be almost the same as creating a row view?

Yes loading multiple views would be slower than a function or view where you iterate your rows in.
#3

[eluser]louis w[/eluser]
I could do some logic in the view. It would have to be recursive so I was trying to get away from adding functions to my view. But I suppose it would be the best, performance wise.
#4

[eluser]Mirage[/eluser]
I don't think that multiple view calls (same as includes) are overly expensive with today's filesystem performance. However, I'd find it a bit overkill to do it at that fine grain.

Along the lines of what xwero said, build up you hierarchy in an array, load the menu view template and loop over it. If the menu hierarchy is somewhat static, you could also put it in a config rather than generating it.

HTH




Theme © iAndrew 2016 - Forum software by © MyBB