Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #447 Add tags to Post (yceruto)
This PR was squashed before being merged into the master branch (closes #447). Discussion ---------- Add tags to Post This implements #44 and it's a complete variant of #192 (On hold since Ago 2016). | Blog Post Index | Post Show | | ---- | --- | | ![tags-index](https://cloud.githubusercontent.com/assets/2028198/22331272/8f0522f8-e398-11e6-8efb-41b8ebb119f4.png) | ![tags-show](https://cloud.githubusercontent.com/assets/2028198/22331381/29aa391a-e399-11e6-9f5a-b09b25a86090.png) | | Post New/Edit | | --- | | ![tagsinput](https://cloud.githubusercontent.com/assets/2028198/22348577/3263128e-e3da-11e6-8b62-25f9720f4275.png) | Also this splits the only one fixture class into three classes (`UserFixtures`, `PostFixtures` and `TagFixtures`): - [x] To prevent mess and complexity. - [x] To avoid post title duplicated (slug issue). - [x] To fix example and explanation of: Sharing objects between fixtures (#192 (comment)). - [x] To add a new example about: Fixture ordering and `DependentFixtureInterface` (dependence between fixtures). Add Translation: - [x] English - [x] Español Updated `blog.sqlite` and `blog_test.sqlite` DBs. --- ### Handling Tags (Bootstrap-tagsinput): There is many options to do that: * Form collection to add new tags? * [`select2`](https://select2.github.io/examples.html) or [`chosen`](https://github.com/harvesthq/chosen) js plugins? * [Bootstrap tagsinput](http://bootstrap-tagsinput.github.io/bootstrap-tagsinput/examples/) js plugin? <-- 👍 * [Tokenfield for Bootstrap](http://sliptree.github.io/bootstrap-tokenfield/) js plugin? ### TODO: - [x] Create TagsInputType to handle the post tags collection (Added DataTransformer example) - [x] Add typeaheadjs option to show tags hint. Commits ------- 46a54dd Add tags to Post
- Loading branch information
Showing
28 changed files
with
708 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{% if not post.tags.empty %} | ||
<p class="post-tags"> | ||
{% for tag in post.tags %} | ||
<span class="label label-success"> | ||
<i class="fa fa-tag"></i> {{ tag.name }} | ||
</span> | ||
{% endfor %} | ||
</p> | ||
{% endif %} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien@symfony.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace AppBundle\DataFixtures\ORM; | ||
|
||
use AppBundle\Entity\Tag; | ||
use Doctrine\Common\DataFixtures\AbstractFixture; | ||
use Doctrine\Common\Persistence\ObjectManager; | ||
|
||
/** | ||
* Defines the sample data to load in the database when running the unit and | ||
* functional tests. | ||
* | ||
* Execute this command to load the data: | ||
* | ||
* $ php bin/console doctrine:fixtures:load | ||
* | ||
* See http://symfony.com/doc/current/bundles/DoctrineFixturesBundle/index.html | ||
* | ||
* @author Yonel Ceruto <yonelceruto@gmail.com> | ||
*/ | ||
class TagFixtures extends AbstractFixture | ||
{ | ||
public static $names = [ | ||
'Lorem', | ||
'ipsum', | ||
'consectetur', | ||
'adipiscing', | ||
'incididunt', | ||
'labore', | ||
'voluptate', | ||
'dolore', | ||
'pariatur', | ||
]; | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function load(ObjectManager $manager) | ||
{ | ||
foreach (self::$names as $index => $name) { | ||
$tag = new Tag(); | ||
$tag->setName($name); | ||
|
||
$manager->persist($tag); | ||
$this->addReference('tag-'.$index, $tag); | ||
} | ||
|
||
$manager->flush(); | ||
} | ||
} |
Oops, something went wrong.