Gallery2:Modules:htmlblock - Gallery Codex
Personal tools

Gallery2:Modules:htmlblock

From Gallery Codex

HTML Block Module

  • Makes blocks available to themes for showing created HTML pages.
  • Display HTML pages.
  • Render template files.

Description

Create HTML pages and templates. Then add them as blocks to pages. Allows for direct links to templates. If you are editing a HTML file, the TinyMCE editor is launched automatically.

Features

  • WYSIWYG HTML editor - TinyMCE
  • Insert images from Gallery
  • Render template files

Usage

  • Download the module here: forums page.
  • Install and activate the module in site admin -> modules
  • Create / Edit your HTML/TPL files
  • Add HTML blocks to your sidebar in site admin -> themes -> matrix (or for any other active/used theme)
  • Add HTML blocks to your album/photo pages in site admin -> themes -> matrix
  • Now you and the visitors of your site see the HTML blocks in your sidebar in all album / photo pages.
  • If displaying full-page HTML pages, you can activate the URL Rewrite section. Pages displayed as http://www.your.site/gallery2/file/MyFile.html
  • if no file is specified for display, it will default to FrontPage.tpl

Examples

to create a homepage for your gallery that may contain anything (including any gallery block)

  • create a FrontPage.tpl file
  • insert your content
  {* display the systemlink *}
  {g->block type="core.SystemLinks"}
  {* display an image *}
  <div>
  {g->block type="imageblock.ImageBlock" blocks="specificItem" maxSize="400"
    itemId=123456 useDefaults=0 showDate=0 showViews=0 showOwner=1 showTitle=1 }
  </div>
  {* display a HTML file *}
  <div>
  {g->block type="htmlblock.HTMLBlock" file="my-content.html"}
  </div>
  {* say hello to your user *}
  <div>
  {capture name="lang"}{g->language}{/capture}
  {assign var="lang" value=$smarty.capture.lang}
  {if $lang == "en-US"}
    {assign var="greeting" value="Hello"}
  {elseif $lang == "ro-RO"}
    {assign var="greeting" value="Salut"}
  {/if}
  {$greeting} {$user.userName}
  </div>

or

  • in main.php, after this line (312 for G2.2.4)
   /* Load and run the appropriate view */

insert this:

    /* Serban: if not embedded and empty view, nor a path, nor an item specified
        go to htmlblock.RenderFile, with no args, so it will take the default, FrontPage.tpl */
    $rewritePath = (isset($_GET[GALLERY_FORM_VARIABLE_PREFIX . 'path']) ?
                    $_GET[GALLERY_FORM_VARIABLE_PREFIX . 'path'] : null);
    $itemId = (int)(isset($_GET[GALLERY_FORM_VARIABLE_PREFIX . 'itemId']) ?
                    $_GET[GALLERY_FORM_VARIABLE_PREFIX . 'itemId'] : null);
    $page = (int)(isset($_GET[GALLERY_FORM_VARIABLE_PREFIX . 'page']) ?
                    $_GET[GALLERY_FORM_VARIABLE_PREFIX . 'page'] : null);

    if (empty($viewName) && !$gallery->isEmbedded() && empty($itemId) && empty($rewritePath) && empty($page)) {
        $viewName='htmlblock.RenderFile';
        GalleryUtilities::putRequestVariable('view', $viewName);
    }
    /* Serban: end of changes for frontpage */

Customization

to allow the tiny mce editor to not remove Javascript tags: Edit /templates/TileEdit.tpl Change:

       extended_valid_elements : "a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]",

to:

       extended_valid_elements : "a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style],script[charset|defer|language|src|type]",

Requested Features

Currently there are no feature requests for this module.

Bugs

Currently there are no known issues for this module.

Multisite

  • In multisite installations I got an error due to some javascript issues (which seem to be a know bug of the used TinyMCE version), replacing the included TinyMCE with V 3.0 solved this
  • Due to security issues it's not possible to use the TinyMCE pop-ups in multisites, so I disabled all of them in FileEdit.tpl
  • With the new TinyMCE 3 I got some UTF8 issues which could be solved with adding entity_encoding : "raw" to the call in FileEdit.tpl

This is the resulting call in FileEdit.tpl:

tinyMCE.init({
entity_encoding : "raw",
mode : "textareas",
theme : "advanced",
plugins : "insertdatetime,print,fullscreen,noneditable,visualchars,nonbreaking",
theme_advanced_disable: "link,unlink,image,anchor,help,visualaid,charmap,css,code",
theme_advanced_buttons1_add : "fontselect,fontsizeselect",
theme_advanced_buttons2_add : "|,insertdate,inserttime,preview,|,forecolor,backcolor",
theme_advanced_buttons2_add_before: "cut,copy,paste,separator",
theme_advanced_buttons3_add : "|,visualchars,nonbreaking,|,print,|,fullscreen",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_path_location : "bottom",
plugin_insertdate_dateFormat : "%Y-%m-%d",
plugin_insertdate_timeFormat : "%H:%M:%S",
extended_valid_elements : "a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]",
content_css: "{/literal}{g->url href="`$theme.themeUrl`/theme.css" forceFullUrl=1}{literal}"
});

Cumgranosalis 15:21, 18 February 2008 (PST)

Planned development

  • better file management
  • drop-down selector for blocks
  • interface look& feel improvement