Commit 25dab749 authored by Hermann Mayer's avatar Hermann Mayer

Added Icon-Support for Page Entity.

parent 950aa60f
<?php
namespace Jity\HomepageBundle\Entity;
namespace Jity\HomepageBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="hp_page")
*/
class Page
/**
* @ORM\Entity
* @ORM\Table(name="hp_page")
*/
class Page
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(type="string", length=100, unique=true)
*/
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(type="string", length=100, unique=true)
*/
protected $slug;
/**
* @ORM\Column(type="string", length=200)
*/
/**
* @ORM\Column(type="string", length=200)
*/
protected $title;
/**
* @ORM\Column(type="text")
*/
/**
* @ORM\Column(type="string", length=200)
*/
protected $icon;
/**
* @ORM\Column(type="text")
*/
protected $content;
/**
* @ORM\ManyToOne(targetEntity="Category", inversedBy="pages")
* @ORM\JoinColumn(name="category_id", referencedColumnName="id")
**/
/**
* @ORM\ManyToOne(targetEntity="Category", inversedBy="pages")
* @ORM\JoinColumn(name="category_id", referencedColumnName="id")
**/
protected $category;
/**
* @ORM\ManyToMany(targetEntity="Media", inversedBy="pages")
* @ORM\JoinTable(name="hp_pages_medias")
**/
/**
* @ORM\ManyToMany(targetEntity="Media", inversedBy="pages")
* @ORM\JoinTable(name="hp_pages_medias")
**/
protected $medias;
/**
* @ORM\ManyToOne(targetEntity="Sidebar", inversedBy="pages")
* @ORM\JoinColumn(name="sidebar_id", referencedColumnName="id")
**/
**/
protected $sidebar;
/**
* @ORM\ManyToOne(targetEntity="Navigation")
* @ORM\JoinColumn(name="navigation_id", referencedColumnName="id")
**/
**/
protected $navigation;
/**
* @ORM\ManyToMany(targetEntity="Navigation", inversedBy="pages")
* @ORM\JoinTable(name="hp_pages_navigations")
**/
/**
* @ORM\ManyToMany(targetEntity="Navigation", inversedBy="pages")
* @ORM\JoinTable(name="hp_pages_navigations")
**/
protected $navigations;
/**
* @ORM\ManyToOne(targetEntity="User", inversedBy="pages")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id")
**/
/**
* @ORM\ManyToOne(targetEntity="User", inversedBy="pages")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id")
**/
protected $author;
......@@ -264,4 +269,47 @@ class Page
{
return $this->author;
}
}
/**
* Set icon
*
* @param string $icon
* @return Page
*/
public function setIcon($icon)
{
$this->icon = $icon;
return $this;
}
/**
* Get icon
*
* @return string
*/
public function getIcon()
{
return $this->icon;
}
/**
* Remove medias
*
* @param Jity\HomepageBundle\Entity\Media $medias
*/
public function removeMedia(\Jity\HomepageBundle\Entity\Media $medias)
{
$this->medias->removeElement($medias);
}
/**
* Remove navigations
*
* @param Jity\HomepageBundle\Entity\Navigation $navigations
*/
public function removeNavigation(\Jity\HomepageBundle\Entity\Navigation $navigations)
{
$this->navigations->removeElement($navigations);
}
}
\ No newline at end of file
......@@ -28,6 +28,7 @@ class PageType extends AbstractType
$builder
->add('slug')
->add('title')
->add('icon')
->add('content')
->add('category', 'entity', array('class'=>'Jity\HomepageBundle\Entity\Category', 'property' => 'name'))
->add('sidebar', 'entity', array('class'=>'Jity\HomepageBundle\Entity\Sidebar', 'property' => 'name'))
......
......@@ -9,10 +9,17 @@
{% set pageUrl = path('home', { 'slug': pageSlug }) %}
{% set activeSlug = (pageSlug == currentSlug ? true : false) %}
<li class="{{ activeSlug ? "active" : "" }}">
{% if page.icon is not empty %}
{% set icon = '<i class="icon-white ' ~ page.icon ~ '"></i> ' %}
{% else %}
{% set icon = '' %}
{% endif %}
{% if activeSlug %}
<a class="">{{ page.title }}</a>
<a class="">{{ icon|raw }}{{ page.title }}</a>
{% else %}
<a class="" href="{{ pageUrl }}">{{ page.title }}</a>
<a class="" href="{{ pageUrl }}">{{ icon|raw }}{{ page.title }}</a>
{% endif %}
</li>
{% endfor %}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment