Skip to content

Instantly share code, notes, and snippets.

View makbeta's full-sized avatar

makbeta makbeta

View GitHub Profile
@makbeta
makbeta / ckeditor.styles.js
Last active August 29, 2015 14:04
Creating custom classes in CKEditor in Drupal
if(typeof(CKEDITOR) !== 'undefined') {
CKEDITOR.stylesSet.add( 'drupal', [
// Block-level styles
{ name: 'Float Left', element: 'p', attributes: { 'class': 'left'} },
{ name: 'Float Right' , element: 'p', attributes: { 'class': 'right'} },
// Inline styles
{ name: 'Small Text', element: 'small' }
] );
@makbeta
makbeta / d7-submitted-info
Last active August 29, 2015 14:24
Change submitted info line that automatically appears on posts in Drupal 7
<?php
THEME_preprocess_node(&$variables, $hook) {
if ($variables['submitted']) {
$variables['submitted'] = t('Posted by !username !datetime', array('!username' => $variables['name'], '!datetime' => format_date($variables['node']->created, 'custom', 'F j, Y')));
}
}
?>
@makbeta
makbeta / d7-disable-wysiwyg-set-format.php
Created October 8, 2015 18:37
D7 modules that sets default format for a field; disables Wisiwyg editor on a set field & summary
<?php
/**
* Implement hook_element_info_alter()
* Enable custom processing of a field in authoring form before it is rendered to the user
*
* @param array $elements
*/
function my_module_element_info_alter(&$elements) {
array_unshift($elements['text_format']['#pre_render'], 'my_module_process_text_format');
}
@makbeta
makbeta / date-as-attribute.html
Created November 30, 2012 01:58
Luminate CMS: How to display a date field in yyyy-mm-dd format as an attribute of an html tag
<t:set id="pdate" value="year(date)" /><t:set id="pdate" value="concat(pdate, '-')" /><t:set id="temp1" value="month(date)+1" />
<t:set id="pdate" value="concat(pdate, temp1)" /><t:set id="pdate" value="concat(pdate, '-')" />
<t:set id="temp2" value="day(date)" /><t:set id="pdate" value="concat(pdate, temp2)" />
<time datetime="${pdate}"><t:value id="date" format="5" /></time>
@makbeta
makbeta / image-sharing.html
Created November 30, 2012 01:55
Luminate CMS: Image Sharing between CMS & CLO
<img src="[[?x0x::x[[S4]]x::http://www.myclodomain.com/images/wrpr/::../images/wrpr/]]logo.png" alt="My Organization" />
@makbeta
makbeta / start-end-date.html
Created November 30, 2012 01:57
Luminate CMS: Displaying a date range (start to end date) with proper formatting
<t:if test="year(start_date) != year(end_date)"><t:value id="start_date" format="5" /> - <t:value id="end_date" format="5" /></t:if>
<t:else>
<t:if test="month(start_date) == month(end_date)"><t:value id="start_date" format="MMMMMMMMMM d" /> - <t:value id="end_date" format="d, yyyy" /></t:if>
<t:else><t:value id="start_date" format="MMMMMMMMMM d" /> - <t:value id="end_date" format="5" /></t:else>
</t:else>
</t:if>
@makbeta
makbeta / category-list.html
Created November 30, 2012 01:59
Luminate CMS: How to render a category (as a comma separated list) in a single display template:
<t:if test="category-field-name.length > 0">
<t:list id="category-field-name">
<a href="list-page.html?category-field-name=${name}">${label}</a><t:if test="index != length">,</t:if>
</t:list>
</t:if>
@makbeta
makbeta / search-stf-pages-conditional.html
Created November 30, 2012 01:56
Luminate CMS: How do I render content in the wrapper on search or send to friend pages only?
<t:if test="title == 'Search Results' || matches(title, 'Send to Friend:.*')">
<div id="maincol"><h1 class="title">${title}</h1>
</t:if>
<div class="templateComponent" id="body"></div>
<t:if test="title == 'Search Results' || matches(title, 'Send to Friend:.*')">
</div>
</t:if>
@makbeta
makbeta / conditional-breadcrumbs.html
Created November 30, 2012 02:13
Luminate CMS: Customize breadcrumbs to not render current page on index pages
<t:if test="matches(path, '.*/')">
<t:include id="breadcrumb-XXXXXXXX" />
</t:if>
<t:else>
<t:include id="breadcrumb-xxxxxxxx" />
</t:else>
@makbeta
makbeta / striped-list-table.html
Created November 30, 2012 02:02
Luminate CMS: How to make a striped list or table?
<style>
div.odd { background: #eee; }
div.even { background: #fff; }
</style>
<div class="striped">
<t:list>
<t:if test="index%2 == 1"><div class="odd"></t:if>
<t:else><div class="even"></t:else>
${title}