Skip to content

Instantly share code, notes, and snippets.

@matdave
Last active July 10, 2018 01:43
Show Gist options
  • Save matdave/4b56db4a570d06ccf9f912a149df5f7c to your computer and use it in GitHub Desktop.
Save matdave/4b56db4a570d06ccf9f912a149df5f7c to your computer and use it in GitHub Desktop.
Build Anchor Menu in Fred.
<section id="{{ anchortext|lower|replace({' ': ''}) }}" >
<div class="container">
<div class="row">
<div class="col-lg-8 mx-auto text-center">
<h2 class="section-heading" contenteditable="true" data-fred-name="head">Header</h2>
<hr class="light my-4">
<div class="text-faded mb-4 text-left" contenteditable="true" data-fred-name="text" data-fred-rte="true" data-fred-rte-config="text">
<p>Some Text</p>
</div>
</div>
</div>
</div>
</section>
<?php
$menu = null;
if(!empty($modx->resource)){
$properties = $modx->resource->get('properties');
if(!empty($properties) && is_array($properties) && !empty($properties['fred']) && !empty($properties['fred']['data'])){
foreach($properties['fred']['data'] as $key=>$values){
if(!empty($values) && is_array($values)){
foreach($values as $value){
if(!empty($value['settings']) && !empty($value['settings']['anchortext'])){
$menu .= $modx->getChunk('fred-menu-tpl', array('anchortext'=>$value['settings']['anchortext'], 'link' => str_replace(" ","", strtolower($value['settings']['anchortext']))));
}
}
}
}
}
}
return $menu;
{
"settings":[
{
"name":"anchortext",
"label":"Anchor Text",
"type": "text",
"value": null
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment