Skip to content

Instantly share code, notes, and snippets.

View davidmars's full-sized avatar
☠️
looking for the skateboard emoji.

david davidmars

☠️
looking for the skateboard emoji.
View GitHub Profile
@davidmars
davidmars / languages-menu.pov.php
Created October 29, 2014 03:52
Display a language menu in a POV FMK View
<ul>
<?foreach(theProject()->hosts() as $h):?>
<li class="one-host-item">
<a href="<?=$h->getUrl()?>" <?=$h->attributesForSEO()?> class="<?=$h->cssIsCurrent("current-language")?>">
<?=$h->language->localName?>
</a>
</li>
<?endforeach?>
</ul>
@davidmars
davidmars / pov-wysiwyg-block-posts-list.php
Created September 4, 2014 07:18
A POV block to manage a post list
<?php
/* @var View $this */
/* @var VV_block $vv */
/** @noinspection PhpUndefinedVariableInspection */
$vv = $_vars;
/** @var VV_post[] $pages */
$pages=$vv->fieldUidsValue("pages");
?>
/**
* For slackers... Quick methos selectors pluggin dealing with attribute names and values.
* @author David Marsalone
* @example $(".myslector").findByAttr("my-attribute-name","my attribute value");
* @example $(".myslector").filterByAttr("my-attribute-name","my attribute value");
*/
(function ( $ ) {
/**
* Quick method to get the descendants of each element in the current set of matched elements, filtered by an attribute name and its value
* @param {string} attributeName The attribute name you are looking for.
@davidmars
davidmars / pov-wysiwyg-img-field-samples.php
Created August 26, 2014 04:22
Some wysiwyg image field sample
<?php
/*
Some image sample
*/
/** @var VV_post|VV_block $vv **/
?>
<img class="ce-que-vous-voulez"
<?=$vv->wysiwyg()
->attrFieldImg
@davidmars
davidmars / is-class-uses-a-trait.php
Last active August 29, 2015 14:03
To know if a class uses a trait
<?php
/**
* To know if a class uses a trait
* @param string $className The class name to inspect
* @param string $traitName The trait class name
* @return bool true if $className uses $traitName
*/
function is_using($className,$traitName){
return in_array($traitName,class_uses($className));
}
@davidmars
davidmars / pov-config-users-roles.php
Created June 27, 2014 03:28
Define what kind of users we will play with...
<?php
//paste this code somewhere in your project config....
//define what kind of users we will play with...
Boot::$events->addEventListener(EVENT_BUILD_MODEL,function($recordType){
if($recordType=="R_user"){
R_user::$roleAdminTextOnlyEnabled=false;
R_user::$roleSimpleHumanEnabled=false;
R_user::$roleWriterEnabled=false;
}
@davidmars
davidmars / pov-format-rich-text-sample.less
Created June 20, 2014 08:40
a sample less css code to format texts into a rich text field (MediumEditor)
[format_string_rich_text]{
h2{
font-family:cursive;
margin-bottom: 4px;
text-align: left;
}
h3{
font-family:cursive;
margin-bottom: 4px;
text-align: left;
@davidmars
davidmars / pov-wysiwyg-rich-text.php
Last active August 29, 2015 14:02
Affiche un champ texte éditable pour l'admin dans lequel il pourra saisir du texte enrichi au moyen de medium-editor.
<?php
/* @var $this View */
/* @var $vv VV_special_page */
$vv = $_vars;
$richTextAttributes="";
if(TheHuman::isAdmin()){
//custom config for the rich text editor, hide and display buttons.
$richText=new RichText();
$richText->h1=true;
$richText->h2=true;
@davidmars
davidmars / pov-display-writer.php
Created June 14, 2014 04:29
Affiche l'auteur d'une page
<?php
/**
* A post page
*/
/* @var $this View */
/* @var $vv VV_post */
/** @noinspection PhpUndefinedVariableInspection */
$vv = $_vars;