Skip to content

Instantly share code, notes, and snippets.

<?php
$list = $page->children()->paginate(10);
$pagination = $list->pagination();
?>
<ul>
<?php foreach($list as $item): ?>
<li><!-- item html --></li>
<ul>
<?php foreach($pages->visible() AS $p): ?>
<li>
<a<?php echo ($p->isOpen()) ? ' class="active"' : '' ?> href="<?php echo $p->url() ?>"><?php echo html($p->title()) ?></a>
<?php if($p->children()->visible()->count()): ?>
<ul>
<?php foreach($p->children()->visible() AS $item): ?>
<li><a<?php echo ($item->isOpen()) ? ' class="active"' : '' ?> href="<?php echo $item->url() ?>"><?php echo html($item->title()) ?></a></li>
<?php endforeach ?>
<?php
if(!r::is_ajax()) notFound();
header('Content-type: application/json; charset=utf-8');
$data = $pages->find('blog')->children()->visible()->paginate(10);
$json = array();
@bugsysop
bugsysop / anchor-child-pages-2.php
Created May 26, 2013 21:34
Anther funtion to list child page. Function to add in function.php
/* Loop
<?php while(get_child()): ?>
// links, img, custom fields
<?php endwhile; ?>
*/
/* Function */
function get_child($original='') {
if( ! Registry::has('page_original')) {
Registry::set('page_original', $original);
@bugsysop
bugsysop / child-pages.php
Created May 26, 2013 16:14
List child page. Function to add in function.php
/*
<?php while(mytheme_page_children()): ?>
<?php echo page_title(); ?>
<?php endwhile; ?>
*/
function mytheme_page_children() {
if( ! Registry::has('page_original')) {
@bugsysop
bugsysop / custom-background.php
Last active December 17, 2015 18:29 — forked from daviddarnes/Anchor Custom Background Image Field
Custom Background Image field for Anchor CMS themes.
<div class="bg-header"
<?php
/*
This is to show a custom field from an article.
It will need to be created in the metadata section before it can be used in the post edit area.
In this case the custom field will need to be called 'image' and be set as an image custom field in the dropdown for type.
*/
$image = article_custom_field('image'); // Applying a variable to the custom field, so it can be reused with ease
if ( !empty($image) ) : // Check if the field is empty, if it is the process stops here
@bugsysop
bugsysop / custom-field.php
Last active December 17, 2015 18:29 — forked from daviddarnes/Anchor Custom Article Field
For outputting a custom field marked with 'image' in the database within an article.
<?php
/*
This is to show a custom field from an article.
It will need to be created in the metadata section before it can be used in the post edit area.
In this case the custom field will need to be called 'image' and be set as an image custom field in the dropdown for type.
*/
$image = article_custom_field('image'); // Applying a variable to the custom field, so it can be reused with ease
if ( !empty($image) ) : // Check if the field is empty, if it is the process stops here
?>
<figure>
@bugsysop
bugsysop / page-selected-cats.php
Created May 25, 2013 22:56
Anchor CMS. Display only selected categories on a page. Code to add in the custom page template.
<?php
// allowCat contains all catergory ID that you want on your page
$allowCat = array(2,3,4,5,6);
function article_category_id() {
if($category = Registry::prop('article', 'category')) {
$categories = Registry::get('all_categories');
return $categories[$category]->id;
}
@bugsysop
bugsysop / anchor-breadcrumbs.php
Created May 25, 2013 22:45
Create a breadcrumbs for Anchor CMS. Add this function in the theme functions.php file.
/*
Usage:
<?php foreach(mytheme_breadcrumbs() as $uri => $name): ?>
<a href="<?php echo $uri; ?>"><?php echo $name; ?></a>
<?php endforeach; ?>
*/
@bugsysop
bugsysop / install.sh
Created May 20, 2013 03:51
Install script for quick static site
#!/bin/bash
#
# Install script for quick static site
# Source : https://github.com/stevedev/html_template
#
curl -L http://github.com/stevedev/html_template/zipball/master > stevedev-html_template.zip
unzip stevedev-html_template.zip
rm -fr stevedev-html_template.zip
mv stevedev-html_template* newsite