PEAK XOOPS - piCalのclass定義でカテゴリ名を使う場合 in englishin japanese

piCalのclass定義でカテゴリ名を使う場合

List posts in the topic

none piCalのclass定義でカテゴリ名を使う場合

msg# 1
depth:
0
Previous post - Next post | Parent - Children.1 .2 | Posted on 2008/1/17 20:03 | Last modified
runaruna  二等兵   Posts: 2
長年piCalを使わせて頂いております。(^人^)感謝♪

そこで以前から悩んでいた
ちょっと嬉しいはずのclass=カテゴリ名でのCSS指定について

CSSのクラス名に日本語っていうのは使えるのかもしれないですが、カテゴリ名にスペースが入ると指定できないですよね?

で、今回改変してみたところ上手く行っているようなので、どなたかの参考になればと思い書き込ませて頂きます。

class>piCal.php の1121行目あたり
元のコード↓※見当たらないときは catname を検索
// サニタイズ
$event->summary = $this->text_sanitizer_for_show( $event->summary ) ;
// categories
$catname = $this->text_sanitizer_for_show( $this->categories[ intval( $event->categories ) ]->cat_title ) ;
// とりあえず半角33字を上限としておく
$summary = mb_strcut( $event->summary , 0 , 33 ) ;
if( $summary != $event->summary ) $summary .= ".." ;
$event_str_tmp = "&bull;&nbsp;<a href='$get_target?smode=Monthly&amp;action=View&amp;event_id=$event->id&amp;caldate=$this->caldate' style='font-size:10px;font-weight:normal;text-decoration:none;' class='$catname'>$summary</a>" ;


改変したコード
// サニタイズ
$event->summary = $this->text_sanitizer_for_show( $event->summary ) ;
// categories
$catname = $this->text_sanitizer_for_show( $this->categories[ intval( $event->categories ) ]->cat_title ) ;
$mycat = $this->text_sanitizer_for_show( $this->categories[ intval( $event->categories ) ]->cid ) ;
// とりあえず半角33字を上限としておく
$summary = mb_strcut( $event->summary , 0 , 33 ) ;
if( $summary != $event->summary ) $summary .= ".." ;
//$event_str_tmp = "&bull;&nbsp;<a href='$get_target?smode=Monthly&amp;action=View&amp;event_id=$event->id&amp;caldate=$this->caldate' style='font-size:10px;font-weight:normal;text-decoration:none;' class='$catname'>$summary</a>" ;
$event_str_tmp = "&bull;&nbsp;<a href='$get_target?smode=Monthly&amp;action=View&amp;event_id=$event->id&amp;caldate=$this->caldate' title='$catname' style='font-size:10px;font-weight:normal;text-decoration:none;' class='piCal_cat$mycat'>$summary</a>" ;

変更点
1)クラス名を cat_title ではなく cid を使ったものに。
以下の行を追加
$mycat = $this->text_sanitizer_for_show( $this->categories[ intval( $event->categories ) ]->cid ) ;

以下の行をコメントアウト
//$event_str_tmp = "&bull;&nbsp;<a href='$get_target?smode=Monthly&amp;action=View&amp;event_id=$event->id&amp;caldate=$this->caldate' style='font-size:10px;font-weight:normal;text-decoration:none;' class='$catname'>$summary</a>" ;


2)cat_title は、リンクのtitleに流用。
以下の行を追加
$event_str_tmp = "&bull;&nbsp;<a href='$get_target?smode=Monthly&amp;action=View&amp;event_id=$event->id&amp;caldate=$this->caldate' title='$catname' style='font-size:10px;font-weight:normal;text-decoration:none;' class='piCal_cat$mycat'>$summary</a>" ;

※最終行の piCal_cat$mycat の piCal_cat は任意の文字列でOK。

一度該当ページを表示させてソースを確認。
class="piCal_cat00001"などを確認して適宜スタイルを定義。
images>default>style.css
.piCal_cat00001{
    background:url(http://xxx.com/modules/cal1/images/default/listicon.gif);
    background-repeat: no-repeat;
    padding: 0 0 0 17px;
    color:blue;
}

こんな感じで今のところ上手く動作していますが何か問題があったらお知らせ下さい。
Votes:6 Average:8.33

Posts tree

  Advanced search


Login
Username or e-mail:

Password:

Remember Me

Lost Password?

Register now!