Thanks so much guys, I can't tell you how much I appreciate your experience 
and suggestions. I guess I need to study up more on Components and how 
they're supposed to work. I'm not really sure what you mean by having the 
component work more "automatically".

If you're willing to provide more insight I would greatly appreciate it - 
otherwise I will do some more homework and see what I can figure out. 
Thanks again!


On Monday, April 9, 2012 8:47:41 PM UTC-5, euromark wrote:
>
> I was more thinking about a more "automatically" working component then
> Which - if enabled - fetches the appropriate meta information for this 
> action and passes it on.
> this component can also add the helper automatically and the helper would 
> do the rest on its own.
> otherwise you are not using the full potential of it.
>
> and using a behavioral approach as Thiago suggested would probably also 
> work.
> But I' probably go for the component.
>
>
> Am Dienstag, 10. April 2012 03:36:48 UTC+2 schrieb Thiago Belem:
>>
>> Why don't you put this getMeta method inside your model or create a 
>> behavior?
>>
>>  
>>
> Thiago Belem
>>
>> Enviado do meu Android (e sujeito a erros do corretor automático)
>> Em 09/04/2012 22:24, "creat1v1ty" escreveu:
>>
>>> Thanks again euromark - I've taken your advice and tips and created a 
>>> SEO Component, which I feel is the best solution. It keeps my MVC 
>>> conventions in tact and hopefully is a more efficient way of doing what I 
>>> need to do.
>>>
>>> Here is what I have now:
>>>
>>> *SeoComponent.php*
>>> =================================
>>> public function getTags($page) {
>>>     App::import('Model', 'Meta');
>>>     $Model = ClassRegistry::init('Meta');
>>>     $seo_data = $Model->find('first', array('conditions' => 
>>> array('Meta.page' => $page)));
>>>     $seo_tags['title'] = $seo_data['Meta']['title'];
>>>     $seo_tags['description'] = $seo_data['Meta']['description'];
>>>     $seo_tags['keywords'] = $seo_data['Meta']['keywords'];
>>>     return $seo_tags;
>>> }
>>>
>>> *PagesController.php*
>>> =================================
>>> public function home($page) {
>>>     $this->set('page', $page);
>>>     $this->set('seo_tags', $this->Seo->getTags($page));
>>> }
>>>
>>> *default.ctp*
>>> =================================
>>> <?php echo $seo_tags['title']; ?>
>>> <?php echo $seo_tags['description']; ?>
>>> <?php echo $seo_tags['keywords']; ?>
>>>
>>>
>>> Please feel free to comment and/or make suggestions on any ways I might 
>>> be able to further refine/improve. Thanks again for all your help!
>>>
>>>
>>>
>>> On Monday, April 9, 2012 7:33:19 PM UTC-5, euromark wrote:
>>>>
>>>> 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 to 
>>>>>> undo your obviously working code. Also not sure how you want to pass 
>>>>>> $page (is it the final url after routing or
>>>>>> the 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 luck
>>>>>> mark
>>>>>>
>>>>>>
>>>>>> 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+unsubscr...@googlegroups.com For more options, visit this 
>>> group at http://groups.google.com/group/cake-php
>>>
>>

-- 
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+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to