List files form setを画像ギャラリーにするテンプレート追加

concrete5 8.2.1
List files form set 1.0.13
参考サイト

参考 【concrete5】List Files From Setを使って画像ギャラリーを作るCLICK ME MAGAZINE

List files form setを使って簡易ギャラリー用のテンプレートを追加してます。
コピー元

/packages/list_files_from_set/blocks/list_files_from_set/templates

コピー先

/application/blocks/list_files_from_set/templates/image_thumbnail

table_layout.php をコピーしてファイル名をview.phpに変更して修正します。
view.php

<?php
use Concrete\Core\Multilingual\Page\Section\Section;

defined('C5_EXECUTE') or die("Access Denied.");

$c = Page::getCurrentPage();
$multilingualSection = Section::getBySectionOfSite($c);

if($c instanceof Page) {
    $cID = $c->getCollectionID();
}

?>

<?php   if ($displaySetTitle && $filesetname = $controller->getFileSetName()) { ?>
<h3><?php   echo $filesetname; ?></h3>
<?php   } ?>

<?php   if (!empty($files)) { ?>    
<table class="fileset-table table">

    <tr><th><?php echo t('Image');?></th>

        <?php  
            if($extension == 'brackets') {
                echo '<th>' . t('Type') . '</th>';
            }

            if ($displaySize) {
                    echo '<th>' . t('Size') . '</th>';
            }


            if ($displayDateAdded) {
                    echo '<th>' . t('Date') . '</th>';
            }

                    echo '<th>' . t('Description') . '</th>';
        ?>


    </tr>


    <?php   
    foreach($files as $f) {

        $fv = $f->getApprovedVersion();
        // although the 'title' for a file is used for display,
        // the filename is retreived here so we can always get a file extension
        $filename = $fv->getFileName();
        $ext =  pathinfo($filename, PATHINFO_EXTENSION);

        if ($forceDownload) {
            $url = $f->getForceDownloadURL();
        } else{
            $url = $f->getDownloadURL();
        }

        // if you wish to directly link to the file, bypassing permissons, logging, etc,
        // use instead of the above line:  $url = $fv->getURL();

        // if we are overriding the filename (e.g. showing only 1 file)
        if ($titleOverride) {
            $title = $titleOverride;
        } else {

            $title = $f->getTitle();

            // want to always use the filename and not the title?  uncomment line below
            // $title = $filename;

            // removes or puts in brackets the file extension
            if ($extension == 'hide') {
                if(strlen($title) - strlen($ext) == strrpos($title,$ext)) {
                    $title = pathinfo($title, PATHINFO_FILENAME);
                }
            } elseif ($extension == 'brackets') {

                if(strlen($title) - strlen($ext) == strrpos($title,$ext)) {
                    $title = pathinfo($title, PATHINFO_FILENAME);
                }
            }

            if ($replaceUnderscores) {
                 $title = str_replace('_', ' ', $title);
            }  

            if ($uppercaseFirst) {
                $title = ucfirst(strtolower($title));
            }

        }

        // サムネイルの取得
        $thumb = $fv->getThumbnailURL('small');
        //$src = $fv->getThumbnailURL('medium');
        $src = $fv->getThumbnailURL('large');

        ?>


        <tr><td>
        <?php //echo \HtmlObject\Image::create($src)->alt($title); ?>
        <a href="<?php echo $src; ?>">
        <img src="<?php echo $thumb; ?>" />
        </a>
        </td>

        <?php  

        if ($extension == 'brackets') {
            echo '<td>' . $ext . '</td>';
        }

        if ($displaySize) {
            echo '<td>' . $fv->getSize() . '</td>';
        }


        if ($displayDateAdded) {
            $dh = Core::make('helper/date');
            echo '<td>' . $dh->formatDate($fv->getDateAdded()) . '</td>';
        }

        if ($multilingualSection) {
           $dstring = explode(";", $fv->getDescription());
         if ($multilingualSection->getLocale() === 'en_US' && count($dstring) > 1){
            echo '<td>' . $dstring[1] . '</td>';
         } else {
            echo '<td>' . $dstring[0] . '</td>';
         }
      } else {
         echo '<td>' . $fv->getDescription() . '</td>';
      }

        ?>


        </tr>



<?php   }   ?>

</table>
<?php   }   ?>

<?php if ($pagination): ?>
    <?php echo $pagination;?>
<?php endif; ?>


<?php   if (empty($files) && $noFilesMessage) { ?>
<p><?php   echo $noFilesMessage; ?></p>
<?php   } ?>
参考 view.phpGist

Monappy: MBDQ39VHypMQwfyR8SshuHvfPNUz321F6B

Monacoinを投げる
モナゲ(tipmona)ってなに?
そもそもMonacoinってなに?

コメントを残す

メールアドレスが公開されることはありません。

このサイトはスパムを低減するために Akismet を使っています。コメントデータの処理方法の詳細はこちらをご覧ください