/*Ovaj kod možemo da pišemo u modules/module.module fajlu ili u themes/module.theme fajlu.
Prvo ide naziv modula (green_deal_core), zatim ide preprocess, i onda naziv template-a kojem hoćemo da prosledimo varijablu (commerce_product__teaser, ovaj template najčešće nalazimo u public_html->themes->custom->templates). Izvorni naziv template-a je sa crticama (-) ali mi to u hook moramo promeniti na underline (_).
Zatim upišemo $varibles['test'] i onda varijablu {{ test }} možemo da koristimo u tom template-u (commerce_product__teaser).
OBAVEZNO MORAMO DA FLAŠUJEMO KEŠ NAKON ŠTO NAPRAVIMO HOOK.
*/
function green_deal_core_preprocess_commerce_product__teaser(&$variables) {
$variables['test'] = '123';
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter