On Tue, Aug 24, 2010 at 9:48 AM, sujandhakal <[email protected]> wrote:
> I'm implementing a cms with multilingual content. i wan to implement
> Translate behavior to the model. Actually I've implemented some of the
> code but its not what i want.
>
> This is my Post Model
>
> <?php
> class Post extends AppModel {
> var $name = 'Post';
> var $displayField = 'title';
>
> var $actsAs = array('Translate'=>array(
> 'title','description'
> ));
>
> }
> ?>
>
> I want to make a translate link at index view with (Edit , View,
> Delete ) link like
> [ Edit | View | Delete | Translate (en | de | np) ]
> on clicking any of those translate link it will lead to a page where i
> can translate the model's content.Please could u make any suggestion.
routes.php:
Router::connect(
'/admin/posts/translate/:id/:lang',
array(
'controller' => 'posts',
'action' => 'translate',
'admin' => 1
),
'id' => '[0-9]+',
'lang' => '[a-z]{2}',
'pass' => array('id', 'lang')
);
posts_controller:
public function admin_translate($id, $lang)
{
if (empty($this->data))
{
$this->data = $this->Post->read(null, $id);
$this->set(compact($lang));
}
else
{
...
}
}
view:
echo $html->link(
'en',
array(
'controller' => 'posts',
'action' => 'translate',
'id' => $data['Post']['id'],
'lang' => 'en'
),
array('title' => 'translate to english')
);
You'll need to pass the id in whatever way you have it available. I've
used a view var, $data, in this case. Leave the admin stuff out if
this isn't supposed to be restricted.
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en