Joomler!.net - Decided on Joomla!

デル株式会社

Wiki or Wordpress? No it is JContentPlus.

Home » Blog » Output GreyBox.js
0 votes
Written by:Joomler! 4113 hits Saturday, 26 January 2008 18:15

少し改造してみた。

http://demo.joomler.net/

各記事上のPDFアイコンとE-Mailアイコンをクリックしてみてください。

GreyBoxを使って表示するようにしてみました。

変更は以下

Root/libraries/joomla/html/html.php

Line:110

return '<a href="'.$url.'" '.$attribs.'>'.$text.'</a>';

$base = substr(JURI::base(), 0, strlen(JURI::base()) - 1);
  $regex = '/<img[^>]*alt="pdf"[^>]*\/>/i';
  if(preg_match($regex, $text)){
   $attribs = ' rel="gb_page_fs[]"';
   $url = $base. $url;
  }
  $regex = '/<img[^>]*alt="E-mail"[^>]*\/>/i';
  if(preg_match($regex, $text)){
   $attribs = $attribs. ' rel="gb_page_center[480, 320]"';
   $url = $base. $url;
  }
  return '<a href="'.$url.'" '.$attribs.'>'.$text.'</a>';

へ変更した。

これだけでは、常時GreyBoxのJavascriptは読み込まれない(プラグインには関係ない)のでテンプレートのheadセクションに以下を追加

<script type="text/javascript">var GB_ROOT_DIR = "<?brush:php; echo $this->baseurl ?>/plugins/content/greybox/"</script>
<script type="text/javascript" src="/<?brush:php; echo $this->baseurl ?>/plugins/content/greybox/AJS.js"></script>
<script type="text/javascript" src="/<?brush:php; echo $this->baseurl ?>/plugins/content/greybox/AJS_fx.js"></script>
<script type="text/javascript" src="/<?brush:php; echo $this->baseurl ?>/plugins/content/greybox/gb_scripts.js"></script>
<link href="/<?brush:php; echo $this->baseurl ?>/plugins/content/greybox/gb_styles.css" rel="stylesheet" type="text/css" />

これは、デフォルトのrhuk_milkywayテンプレートの場合です。

これによって常時GreyBoxのJavascriptがロードされるのでGreyBoxプラグインをインストールしている場合は、Output GreyBox.jsをNoに変更してください。

output_no_greybox

参考にGreyBoxを使ってみましたが、同様にLightBox、ThickBox、LightWindowなど他の画像表示のJavascriptにも応用できるでしょう。

HTMLが表示できるJavascriptライブラリでないと無理でしたね。

 

JContentPlus for Joomla!1.5 powered by Joomler!.net

デル株式会社
joomler.net is not affiliated with or endorsed by the Joomla! Project or Open Source Matters.
The Joomla!(R) name is used under a limited license from Open Source Matters in the United States and other countries.
joomler.net is not affiliated with or endorsed by Open Source Matters or the Joomla! Project.