-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve Quick Start Guide #22
Comments
How do you suggest improving it? |
@jadb can you add screenshots, a picture is worth 1000 words |
@mistaguy, screenshots of? |
Agree with matthiasmoritz I've been spending about 3 hours so far going though the code trying to figure out how to display the tags once they're added. |
@zhunt I have the same problem: I was able to add the tag but was not able to load it : any hint? |
I've not tried the plugin but taking a look to the behavior it adds relation to the $this->Posts->find('all', ['contain' => ['Tagged.Tags']]); |
This works: $this->Posts->find('all', ['contain' => ['Tags']]); and in your view simply loop through the tags: <th><?= __('Tags') ?></th>
<td>
<?php foreach ($post->tags as $tag): ?>
<?= h($tag->label) ?>
<?php endforeach; ?>
</td> |
I used this way to modify tags: Controller $delimiter = ','; // same as delimiter at TagBehavior $tags = []; View |
How to edit associated tags? In my edit.ctp, in the input for tags instead of seeing the tag name I see the whole object. For example I have 3 tags associated with a specific article: "test1", "test2" and "test3". When the form is rendered, in the input I get this: Any advise? |
@virusvn your solution gives me the following warnings:
Suggestions to get rid of these? |
@chrmina |
@virusvn the errors come just after saving. Here is my edit method:
|
@chrmina sorry for late reply, `
Sorry for have no-good explanation |
@virusvn thank you for your reply. The problem was resolved by simply rearranging the code as below: public function edit($id = null)
{
$document = $this->Documents->get($id, ['contain' => ['Tags']]);
if ($this->request->is(['patch', 'post', 'put'])) {
$document = $this->Documents->patchEntity($document, $this->request->data);
if ($this->Documents->save($document)) {
$this->Flash->success(__('The document has been saved.'));
return $this->redirect(['action' => 'index']);
} else {
$this->Flash->error(__('The document could not be saved. Please, try again.'));
}
}
// Manage Tags
$delimiter = ','; // same as delimiter at TagBehavior
$tags = [];
$alltags = $document->tags;
foreach ($alltags as $tag):
$tags[] = $tag->label;
endforeach;
$document->tags = implode($delimiter, $tags);
$this->set(compact('document'));
} |
After following the instructions in the Quick Start Guide, the tags field (e.g. in edit.ctp) is not auto-polulated with the tags.
The text was updated successfully, but these errors were encountered: