Open antonkomarev opened 9 years ago
We need to think around that widget features.
All cases i could imagine for tags widgets but not sure all of them will be really useful:
<li>
elements (main goal of widget)./post/tag/awesome-tag
-> will display all posts tagged as awesome-tag
/tag/awesome-tag
-> will display all model types tagged as awesome-tag
(posts
, articles
& news
for example).<span>
.It's more than one widget described here. Let the discussion be started! :}
@a-komarev
I think 1+2+3+4+5+8 = one widget. And 9 = other widget.
Separate repository with require will be better solution.
I do not think its good idea since taggable
name choosed not only for behavior, but for highly reusable components around tagging staff.
@a-komarev As i see we have 2 widgets here (except 6,7,10): TagWidget
and TagCloudWidget
. Both use Menu
for rendering.
6, 7, 10 are for TagInputWidget
. But they should be implemented as button to quick edit in TagWidget
. When you click on it - TagWidget
replacing by TagInputWidget
. Which will be replaced by TagWidget
when you are pressing buttons Save or Cancel.
Display widgets should be able to replace spaces in links with +
sign. It's W3C standard:
URLs cannot contain spaces. URL encoding normally replaces a space with a plus (+) sign or with %20.
Example:
Tag url good practice
should be linked to /tag/url+good+practice
@a-komarev It already handled by framework.
Am I missed something?
<?php foreach ($model->tagNames as $tag) : ?>
<?= Html::a($tag, ['/tag/' . $tag]) ?>
<?php endforeach ?>
This code generating me links with spaces: /tag/url good practice
.
@a-komarev
Am I missed something?
Yes, ofcource. This:
<?= Html::a($tag, ['/tag/' . $tag]) ?>
is not right solution. Such tasks should be solved by configuring urlManager
rules + using code like this:
<?= Html::a($tag, ['/tag/index', 'tag' => $tag]) ?>
or even better:
<?= Html::a($tag, ['/tag/index', 'tagSlug' => $tagSlug]) ?>
Last example when Tag
model use SluggableBehavior
.
Rules example:
'rules' => [
'tag/<tag>' => 'tag/index',
// or
'tag/<tagSlug>' => 'tag/index',
],
@creocoder Thanks for a brief explanation! And this way more flexible for multiple tags filtering I suppose.
I reserved tag/index
method for list of all tags and tag/view
is working well now. Tags are passing through params with +
sign instead of spaces.
<?php foreach ($model->getTagNames(true) as $tag) : ?>
<?= Html::a($tag, ['/tag/view', 'tag' => $tag]) ?>
<?php endforeach ?>
Haven't thought about SluggableBehavior for tags, but sounds interesting. Will be great to have an example of this way in wiki of this repository.
@a-komarev Can you open separate documentation issue? We can explain how to set up urlManager
+ show controller and other examples inside Advanced Usage
section.
Have you planned to create a widget to display tags with links on them in view actions or this repository will contain only TaggableBehavior? IMHO: Separate repository with require will be better solution.