Skip to content

Instantly share code, notes, and snippets.

@phenix-factory
phenix-factory / Autosubmit_form.js
Last active December 15, 2015 02:29
jQuery: soumettre automatiquement un formulaire.
/**
* Il faut simplement placer la classe autosubmit sur la balise form
* pour déclencher l'autosoumision du formulaire.
*/
$(function () {
// Dès qu'il y a un changement dans la formulaire.
$(".autosubmit select").on("change", function () {
// On demande confirmation du changement de statut.
if (confirm("Etes-vous sur ?")) {
@phenix-factory
phenix-factory / age.php
Last active December 15, 2015 02:29
PHP: renvoie l'age en fonction d'une date.
<?php
/*
* Calcule l'age en fonction de la date de naissance
* Format de date type 12/06/1988
*/
function age($date) {
/*
* Cette adaptation est obligatoire si on utilise un format de date "Français",
* strtotime ne supporte que le format d-m-Y et pas d/m/Y.
*/
@phenix-factory
phenix-factory / Wordpress_core.css
Created March 18, 2013 14:43
Wordpress: CSS de base pour les articles Wordpress
/* =WordPress Core
-------------------------------------------------------------- */
.alignnone {
margin: 5px 20px 20px 0;
}
.aligncenter, div.aligncenter {
display:block;
margin: 5px auto 5px auto;
}
@phenix-factory
phenix-factory / render_drupal_block.php
Last active December 15, 2015 02:39
Drupal: render un block drupal spécifique.
<?php
/*
* Fait un rendu d'un block drupal.
* Il faut lui passer le type (Block, menu, node) et le nom machine.
*/
$block = block_load('type', 'machine_name');
/* Me demandez pas ce que ça fait, j'en ai aucune idée, mais ça marche. */
$render_block = _block_get_renderable_array( _block_render_blocks(array($block)));
print render($render_block);
@phenix-factory
phenix-factory / drupal_submenu_node.php
Last active December 15, 2015 03:38
Drupal: aller chercher le sous menu de la node en cour.
<?php
/*Ne pas oublier d'aller chercher le bon chemin de node !*/
$path = 'node/'.$node->nid;
$parent = menu_link_get_preferred($path);
$parameters = array(
'active_trail' => array($parent['plid']),
'only_active_trail' => FALSE,
'min_depth' => $parent['depth']+1,
'max_depth' => $parent['depth']+1,
'conditions' => array('plid' => $parent['mlid']),
@phenix-factory
phenix-factory / youtubeBackground.html
Created April 1, 2013 19:22
HTML: vidéo Youtube en fond de site web
<div style="position: fixed; z-index: -99; width: 100%; height: 100%">
<iframe frameborder="0" height="100%" width="100%" src="https://youtube.com/embed/VIDEO_ID?autoplay=1&controls=0&showinfo=0&autohide=1"></iframe>
</div>
@phenix-factory
phenix-factory / YoutubeMusic.html
Created April 1, 2013 19:24
HTML: mettre une music youtube sur un site web (Invisible)
<embed height="0" width="0"src="http://youtube.googleapis.com/v/VIDEO_ID&autoplay=1&loop=1" />
@phenix-factory
phenix-factory / submitForm.js
Last active December 16, 2015 03:38
jQuery: soumettre une formulaire via un événement click
// Quand on click sur le bouton de recherche
$("#bouton_recherche").click(function () {
// On soumet le formulaire
$("#form_recherche").submit();
});
@phenix-factory
phenix-factory / focusInput.js
Last active December 16, 2015 03:39
jQuery: Simuler un PlaceHolder avec du javascript.
jQuery(document).ready(function($) {
// Le sélécteur de champ.
var typeInput = $("input[type=text], input[type=password], input[type=search], input[type=email]");
// Quand on un champ de formulaire prend le focus
typeInput.on("focusin", function () {
// On récupère ça valeur
value = $(this).val();
// Si c'est la valeur par défaut, on vide le champs.
if (value == this.defaultValue) $(this).val("");
@phenix-factory
phenix-factory / article-seul-traduction.html
Last active December 16, 2015 05:59
SPIP: Boucle pour afficher un article SPIP ou ça traduction
<BOUCLE_article(ARTICLES){id_article=5}>
<BOUCLE_traduction(ARTICLES){traduction} {lang=#ENV{lang}}>
<h1>#TITRE</h1>
[<div class="chapo">(#CHAPO)</div>]
#TEXTE
</BOUCLE_traduction>
</BOUCLE_article>