Skip to content

Instantly share code, notes, and snippets.

@dlfinis
dlfinis / liferay-journal-article-image-xml
Created May 19, 2015 17:45
Application Display Template (ADT) to display nested repeatable elements (images)
#if (!$entries.isEmpty())
<div class="news">
#foreach ($entry in $entries)
#set($renderer = $entry.getAssetRenderer() )
#set($className = $renderer.getClassName() )
#if( $className == "com.liferay.portlet.journal.model.JournalArticle" )
#set( $journalArticle = $renderer.getArticle() )
#set( $document = $saxReaderUtil.read($journalArticle.getContent()) )
#set( $rootElement = $document.getRootElement() )
#set( $xPathSelector = $saxReaderUtil.createXPath("dynamic-element[@name='Image_Text']/dynamic-element[@name='Image10593']") )
@dlfinis
dlfinis / liferay-read-journal-article-xml
Last active August 29, 2015 14:21
Read the content of a Journal Article by xml with saxreader
## An list with elements
##Check if have elements
#if (!$listaArticulos.isEmpty())
#foreach ($entry in $listaArticulos)
#set ($doc = $saxReaderUtil.read($entry.getContentByLocale($entry.getDefaultLocale())))
#set ($rootEl = $doc.getRootElement())
@dlfinis
dlfinis / check-jquery
Created May 14, 2015 15:13
Check if exits an jquery script load
## One way
if(!("jQuery" in window)) {
var head = document.getElementsByTagName('head')[0],
script = document.createElement('script');
script.type = 'text/javascript';
script.src = '/resources/js/lib/jquery-2.1.0.min.js';
head.appendChild(script);
}
@dlfinis
dlfinis / liferay-web-content-journal
Last active May 18, 2017 02:17
Web Content Liferay access to Journal Objects
##Check that have added these properties in the portal-ext.properties file
journal.template.velocity.restricted.variables=
velocity.engine.restricted.classes=
velocity.engine.restricted.variables=
## Way to add a web content by id
#set ($group_id = $getterUtil.getLong($request.theme-display.scope-group-id))
#set ($webcontent-id = "0101")
#set ($webcontent=$journalContentUtil.getContent($group_id, $webcontent-id, "", "$locale", ""))
@dlfinis
dlfinis / reemplazo-cadenas
Created May 7, 2015 23:13
Reemplazo de Cadenas
### [Utilizacion en entornos/herramientas que utilizen comandos de GNU/Linux]
### Ubicarse en el directorio que se reemplazaran las cadenas
##Recursivo
grep -rl 'windows' ./ | xargs sed -i 's/windows/linux/g'
##Incluido elementos ocultos
find . -type f -exec sed -i 's/foo/bar/g' {} +
@dlfinis
dlfinis / Admin Dockbar
Created April 21, 2015 14:40
Show the dockbar only with admin users.
#if (($permissionChecker.isOmniadmin())||$permissionChecker.isCompanyAdmin($themeDisplay.getCompanyId())||
$permissionChecker.isCommunityAdmin($themeDisplay.getScopeGroupId()))
#dockbar()
#end
@dlfinis
dlfinis / 0_reuse_code.js
Last active August 29, 2015 14:19
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@dlfinis
dlfinis / colors.xml
Created February 7, 2015 01:07
Color Palette of Material Design
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="red_50">#fde0dc</color>
<color name="red_100">#f9bdbb</color>
<color name="red_200">#f69988</color>
<color name="red_300">#f36c60</color>
<color name="red_400">#e84e40</color>
<color name="red_500">#e51c23</color>
<color name="red_600">#dd191d</color>
<color name="red_700">#d01716</color>
@dlfinis
dlfinis / Share with Apps - Simple
Created December 20, 2014 19:43
Button Listener to share content with other App
private View.OnClickListener btnShare_onClickListener= new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent textShareIntent = new Intent(Intent.ACTION_SEND);
textShareIntent.putExtra(Intent.EXTRA_TEXT,getString(R.string.message_share));
textShareIntent.setType("text/plain");
//startActivity(textShareIntent);
// ^^ this auto-picks the defined default program for a content type, but since we want users to
// have options, we instead use the OS to create a chooser for users to pick from
@dlfinis
dlfinis / Auto-Close Dialog
Created December 19, 2014 22:05
Button Listener with auto-close Alert Dialog
private View.OnClickListener btnJagger_onClickListener = new View.OnClickListener() {
String message="";
@Override
public void onClick(final View v) {
AlertDialog.Builder builder = new AlertDialog.Builder(v.getContext());
message=(getString(R.string.thanks)+"\n"+getString(R.string.about)) ;
builder.setTitle(R.string.company_name);