當前位置: 首頁>>代碼示例>>PHP>>正文


PHP SiteHelper::getSlug方法代碼示例

本文整理匯總了PHP中SiteHelper::getSlug方法的典型用法代碼示例。如果您正苦於以下問題:PHP SiteHelper::getSlug方法的具體用法?PHP SiteHelper::getSlug怎麽用?PHP SiteHelper::getSlug使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在SiteHelper的用法示例。


在下文中一共展示了SiteHelper::getSlug方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: actionIndex

 /**
  * This is the default 'index' action that is invoked
  * when an action is not explicitly requested by users.
  */
 public function actionIndex()
 {
     $limit = 50;
     $p = (int) Yii::app()->request->getParam("p", 1);
     $catalog = Yii::app()->request->getParam("catalog", "");
     Yii::app()->page->title = "Выставить слаг";
     if (!empty($catalog)) {
         $catalogS = SiteHelper::getCamelCase($catalog);
         $items = $catalogS::fetchAll(DBQueryParamsClass::CreateParams()->setLimit($limit)->setCache(0)->setPage($p));
         sizeof($items);
         for ($i = 0; $i < sizeof($items); $i++) {
             $items[$i]->slug = SiteHelper::getSlug($items[$i]);
         }
         if (sizeof($items) > 0) {
             $this->redirect(SiteHelper::createUrl("/console/SetSlug", array("catalog" => $catalog, "p" => $p + 1)));
         }
     } else {
         $items = array();
     }
     $this->render("index", array("items" => $items));
 }
開發者ID:bogiesoft,項目名稱:yii-travel,代碼行數:25,代碼來源:SetSlugController.php

示例2: setTranslate

 public static function setTranslate($model, $transModel, $lang = "en")
 {
     $lA = explode("-", $lang);
     $lang = $lA[0];
     $name = TranslateHelper::translate($model->name, $lang);
     if (property_exists($model, "description")) {
         if ($model->description) {
             $text = TranslateHelper::translate($model->description, $lang);
         } else {
             $text = "";
         }
     }
     $text = str_replace(array("< p", "< div"), array("<p", "<div"), $text);
     $requiredFields = $model->getSafeAtributes();
     for ($i = 0; $i < sizeof($requiredFields); $i++) {
         $field = trim($requiredFields[$i]);
         $transModel->{$field} = $model->{$field};
     }
     $transModel->id = $model->id;
     $transModel->name = $name;
     if (property_exists($transModel, "location")) {
         if ($model->location) {
             $transModel->location = TranslateHelper::translate($model->location, $lang);
         }
     }
     if (property_exists($transModel, "address")) {
         if ($model->address) {
             $transModel->address = TranslateHelper::translate($model->address, $lang);
         }
     }
     if (property_exists($model, "description")) {
         $transModel->description = $text;
     }
     if (!$transModel->save()) {
         print_r($transModel->getErrors());
     } elseif (property_exists($transModel, "slug")) {
         SiteHelper::getSlug($transModel);
     }
 }
開發者ID:bogiesoft,項目名稱:yii-travel,代碼行數:39,代碼來源:TranslateHelper.php

示例3:

<?php

if (!$tour->slug) {
    $tour->slug = SiteHelper::getSlug($tour);
}
$listImages = ImageHelper::getImages($tour, 1);
?>

<div class="IBItem IBTours">
    <?php 
if ($tour->price > 0) {
    ?>
<p><?php 
    echo Yii::t("page", "цена");
    ?>
:<b><?php 
    echo $tour->price;
    ?>
</b>у.е.</p><?php 
}
?>
    <?php 
if ($tour->col > 0) {
    ?>
<div class="floatRight rightInfo"><?php 
    echo Yii::t("page", "просмотров");
    ?>
: <b><?php 
    echo $tour->col;
    ?>
</b></div><?php 
開發者ID:bogiesoft,項目名稱:yii-travel,代碼行數:31,代碼來源:tour.php

示例4:

<?php

if (!$item->slug) {
    $item->slug = SiteHelper::getSlug($item);
}
$images = ImageHelper::getImages($item, 1);
?>

<div class="IBItem">
    <?php 
if (sizeof($images) > 0) {
    ?>
        <div class="IBIImage">
            <a href="<?php 
    echo SiteHelper::createUrl("/" . $link . "/description") . "/" . $item->slug;
    ?>
.html" title="<?php 
    echo SiteHelper::getStringForTitle($item->name . "," . $item->firm_id->name);
    ?>
"><img src="<?php 
    echo ImageHelper::getImage($images[0]->image, 2);
    ?>
" alt="<?php 
    echo SiteHelper::getStringForTitle($item->name . "," . $item->firm_id->name);
    ?>
" /></a>
        </div>
    <?php 
}
?>
    <?php 
開發者ID:bogiesoft,項目名稱:yii-travel,代碼行數:31,代碼來源:item.php


注:本文中的SiteHelper::getSlug方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。