示例#1
0
 public static function getSlug(CCModel $item)
 {
     if (empty($item->slug) || !$item->slug) {
         $nameForSlag = str_replace(array("\$"), "", $item->name);
         $nameTranstlit = SiteHelper::getTranslateForUrl($nameForSlag);
         $dopSlug = $item->id . "-";
         if (property_exists($item, "owner") && $item->owner->id > 0) {
             $dopSlug .= SiteHelper::getTranslateForUrl($item->owner->name);
         } else {
             $dopSlug .= "";
         }
         if (property_exists($item, "category_id") && !empty($item->category_id) && $item->category_id->id > 0) {
             $dopSlug .= SiteHelper::getTranslateForUrl($item->category_id->name);
         }
         if (get_class($item) == "CatalogHotels") {
             $dopSlug = SiteHelper::getTranslateForUrl($item->country_id->name);
             if ($item->city_id->id > 0) {
                 $dopSlug .= "-" . SiteHelper::getTranslateForUrl($item->city_id->name);
             }
         }
         // Проверяем чтобы название категории не содержалось в названии чтобы не было такого: banki-banki-tashkenta
         if (!empty($dopSlug) && strpos($nameTranstlit, $dopSlug) !== false) {
             $dopSlug .= "";
         }
         if (!empty($dopSlug)) {
             $item->slug = $dopSlug . "-" . $nameTranstlit;
         } else {
             $item->slug = $nameTranstlit;
         }
         $item->slug = str_replace(array("---", "--"), "-", $item->slug);
         $item->save();
     }
     return $item->slug;
 }
示例#2
0
    ?>
</b></span></div><?php 
}
?>
            <br/>
            <?php 
echo Yii::t("page", "страна");
?>
: <a href="<?php 
echo SiteHelper::createUrl("/country") . "/" . $item->slug;
?>
.html" title="<?php 
echo Yii::t("page", "туристическая страна");
?>
 <?php 
echo SiteHelper::getTranslateForUrl($item->country_id->name);
?>
"><?php 
echo $item->country_id->name;
?>
</a><br/>
            <?php 
echo Yii::t("page", "категория");
?>
:<a href="<?php 
echo SiteHelper::createUrl("/tours") . "/" . $item->category_id->slug;
?>
.html" title="<?php 
echo SiteHelper::getStringForTitle($item->category_id->name);
?>
"><?php