sfPropelFriendlyUrlBehaviorPlugin - 1.0.1
Symfony Friendly Url Plugin
You are currently browsing
the website for symfony 1
A behavior to automatically generate friendly url keys from text within models.
A plugin to automatically generate user friendly url keys from model objects. You can configure the plugin to use a text column to generate url keys and to store in another column or plugin's own table. You can also retrieve your objects using utility classes.
|Umut Utkan||lead||gro.aadyoh <<ta>> naktu.tumu|
Copyright (c) 2007 Hoydaa Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
This plugins allows you to automatically generate friendly url keys for your model objects based on the text contained in a column selected.
Install the plugin
symfony plugin-install http://plugins.symfony-project.com/sfPropelFriendlyUrlBehavior
Enable Propel behavior support in
propel.builder.AddBehaviors = true
Activate the behavior for one of your Propel models, specifying the name of the source column and/or target column. The behavior has two possible use cases. You can either store stripped title in a column you specified as target_column on the same table as your model or you can let the behavior to handle it in behavior's own table. Do not choice the second option if you have performance issues, because every time $my_obj->getFriendlyUrl() method is requested on the background the this value will be brought from this table and that will cause a couple of extra sql executions.
sfPropelBehavior::add('Snippet', array( 'sfPropelFriendlyUrlBehavior' => array( 'source_column' => 'title', 'target_column' => 'stripped_title' ) ) );
There is no extra configuration, the behavior will bound a new method to the model object. In order to get the stripped text you can call getFriendlyUrl method on your model object.
Unfortunately, as of PHP 5, static method calls cannot be caught by a __call(). This means that symfony behaviors are not able to add new methods to the Peer classes. This means that it is not possible to bound a static method like retrieveByFriendlyUrl to Peer class. However there is a utility class with one method retrieveByFriendlyUrl, you can use this method to retrieve your model object using it's friendly url.