Re: SEO/Meta Data Helper
I am not saying you can never break MVC or cake conventions. I do so myself occasionally. But it should have sane reasoning then.
In your case it could be also solved using a component which does what you are doing in the view - fetching the data from the model.
It could then pass it down to the view level where you only have to display it.
That would be in MVC (fetching model data in the view layer is considered breaking it).
But your solution simplifies the task. So as long as it doesn't break other (real) things it is not completely wrong to intentionally go down this road.
Am Dienstag, 10. April 2012 00:07:24 UTC+2 schrieb creat1v1ty:
Thanks very much for the insights, euromark. Here is some additional info based on your questions:
Not sure if breaking MVC is really the best way to go here - breaking MVC is not something I am doing intentionally. To be completely honest, I don't know how doing what I'm doing breaks MVC...perhaps you can help me understand that. My goal is to keep my code as clean and semantic as possible.
Also not sure how you want to pass $page (is it the final url after routing or the prefix/plugin/controller/action/ string?) - for the pages of the site that are managed by the PagesController, I am relying on the default variable Cake uses ($page), which is set in routes.php.
ex: Router::connect('/about', array('controller' => 'pages', 'action' => 'display', 'about'));
For pages not managed by the PagesController, I am setting the $page variable for each action in that controller.
ex: $this->set('page', 'contact-index');
If you want people to contribute and discuss your code in detail, you should open a github rep for it - I appreciate the tip and will definitely keep this in mind going forward. With this request, however, the code I've written is pretty minimal - the extent of it is in my original post. I do understand, however, that seeing code in its context is much more efficient.
PS: it also sounds like something that could be made a "Seo" plugin to make it available for multiple apps. - I agree completely, and would love to pass something beneficial along to others to use as well. However, I don't really feel comfortable pitching something that isn't built correctly, or outside of MVC conventions. Also, I don't really have the experience with Cake to understand what's needed to build a plugin, and how I can take what I've done and turn it into one. That being said, I am definitely open to suggestions and help in doing it.
Thanks again, euromark.
On Monday, April 9, 2012 4:31:33 PM UTC-5, euromark wrote:IF you really need to use a model in this context you should never use "new" but ClassRegistry:$Model = ClassRegistry::init('Meta');Not sure if breaking MVC is really the best way to go here. But if it works for you, nobody will force you toundo your obviously working code. Also not sure how you want to pass $page (is it the final url after routing orthe prefix/plugin/controller/action/ string? both solutions could work, might have different pros and cons. Other than that it looks fine. I know there are some plugins which do it not that much different you do.Without specific inside in your application there is only so much one can suggest.Just take the "silence" regarding your thread as a "not beautiful, but not really problematic either".Everything else is your thing. Not ours.If you want people to contribute and discuss your code in detail, you should open a github rep for it.So others can fork or submit issues. Reading through a lot of code without code highlighting is no fun.PS: it also sounds like something that could be made a "Seo" plugin to make it available for multiple apps.you never know when you will need it (or others for that matter). Just something to think about.But then use: `$Model = ClassRegistry::init('Seo.Meta');` :) good luckmark
Am Montag, 9. April 2012 21:37:51 UTC+2 schrieb creat1v1ty:anyone out there have any suggestions/recommendations for me?
Thanks in advance.
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home