User Tools

Site Tools


cheatsheet

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
cheatsheet [2023/08/24 20:16] – [Themes and Style Sheets] 67.186.161.147cheatsheet [2023/08/29 13:16] (current) – external edit 127.0.0.1
Line 572: Line 572:
     SelectAttributeTypeOption::add( $mMakerAttribute, 'Select Option Three');     SelectAttributeTypeOption::add( $mMakerAttribute, 'Select Option Three');
  }  }
-?> 
-</code> 
- 
-=====  Select Nav Based On Page Attributes ===== 
-<code php> 
-(See language Switching) 
- 
-<?php 
-  if ($c->getCollectionAttributeValue('spanish_menus')) { 
-    $block = Block::getByName('Spanish Menus'); 
-    if( is_object($block) ) $block->display(); 
-  } else { 
-    $block = Block::getByName('English Menus'); 
-     if( is_object($block) ) $block->display(); 
-   } 
 ?> ?>
 </code> </code>
Line 1058: Line 1043:
   usort($pages, create_function('$a, $b', 'return $a->getAttribute("end_date") > $b->getAttribute("end_date");'));   usort($pages, create_function('$a, $b', 'return $a->getAttribute("end_date") > $b->getAttribute("end_date");'));
 ?> ?>
 +</code>
 +
 +====== Working With Languages ======
 +=====  Get Active Language =====
 +<code php>
 +  $lang = \Localization::activeLocale();
 +</code>
 +
 +=====  Get Default Language =====
 +<code php>
 +  $app = \Concrete\Core\Support\Facade\Application::getFacadeApplication();
 +  $site = $app->make('site')->getSite();
 +  $defaultLang = $site->getDefaultLocale()->getLocale();
 </code> </code>
  
cheatsheet.txt · Last modified: 2023/08/29 13:16 by 127.0.0.1