Instantly share code, notes, and snippets.

View If-different-block-type.html
<perch:if different="_block_type">
This is a different block type
</perch:if>
View perch-blog-template.php
<?php
if (perch_layout_has('blog-post')) {
perch_blog_post_meta(perch_get('s'));
perch_page_attributes();
}else{
echo '<title>' . perch_pages_title(true) . '</title>';
perch_page_attributes();
}
?>
View excluding-categories.php
// We're grabbing each category and filtering the 'Properties' region using that category - if the property count is 0, we don't pass that category to the output.
// This method does produce a database query for each category, so I would run it with debug switched on to see if makes an impact for your setup or not.
<?php perch_categories(['set'=>'area','sort'=>'catTitle','sort-order'=>'ASC','each'=>function($item) {
if (PerchUtil::count(perch_content_custom('Properties',
['skip-template'=>true, 'category'=>$item['catPath']])) > 0) return $item; }]
); ?>
// You do have to make a slight change to the category template with this though - an example using the default category.html template:
View sidebarcode.php
<?php
perch_blog_custom(array(
'filter' => 'postSlug',
'match' => 'neq',
'value' => perch_get('s'),
'sort'=>'postDateTime',
'sort-order'=>'DESC',
'count'=>1,
'template'=>'blog/post_in_list_sidebar.html'
));
View heading-arrows.css
h1 {
background: #000000;
color: #FFFFFF;
font-size: 20px;
font-weight: bold;
padding: 5px;
position: relative;
}
h1:after {
border-color: #000000 transparent transparent;
View config.js
Perch.UserConfig.redactor = function(){
var get = function(profile, config, field) {
return { buttons: ['bold', 'italic'] }
};
var load = function(cb) {
cb();
};
View config.js
Perch.UserConfig.redactor = function(){
var get = function(profile, config, field) {
if (config.plugins.indexOf('source') === -1) config.plugins.push('source');
if (config.plugins.indexOf('fontcolor') === -1) config.plugins.push('fontcolor');
if (config.plugins.indexOf('alignment') === -1) config.plugins.push('alignment');
return config;
};
View after-content-hook.php
function after_post_content($content) {
if(!is_feed() && !is_home()) {
$content.= '<h4>Like this post?</h4>';
$content.= '<p><a href="http://example.com/subscribe">Subscribe to our newsletter</a>!</p>';
}
return $content;
}
add_filter ('the_content', 'after_post_content');
View formselectoptions.html
<perch:label for="subject">Subject</perch:label>
<perch:input type="select" id="subject" options="<perch:content id="subject" type="text" label="Subject" help="Add subjects separated by commas" />" id="subjectoptions" />
View arrows-wth-css.html
<div class="arrow_box">
<h1 class="logo">css arrow please!</h1>
</div>