Skip to content

Instantly share code, notes, and snippets.

View husseinalhammad's full-sized avatar
🇵🇸
🇵🇸 I stand with Palestine

Hussein Al Hammad husseinalhammad

🇵🇸
🇵🇸 I stand with Palestine
View GitHub Profile
@husseinalhammad
husseinalhammad / perch_collection_similar_items.php
Created October 1, 2020 15:46
Get similar Perch Collection items
<?php
// get the main item for the detail page
// assuming you're getting the slug from the URL
$item = perch_collection('Case Studies', [
'template' => 'case_studies/_detail',
'skip-template' => true,
'return-html' => true,
'filter' => 'slug',
'value' => perch_get('s'),
@husseinalhammad
husseinalhammad / perch_blog_post.html
Created January 4, 2020 13:36
Perch Blog default post.html template
<article class="h-entry">
<h1>
<a href="<perch:blog id="postURL" type="hidden" />" rel="bookmark" class="p-name">
<perch:blog id="postTitle" type="text" label="Title" required="true" size="xl autowidth" order="1" />
</a>
</h1>
<p class="meta">
<time class="dt-published" datetime="<perch:blog id="postDateTime" type="date" label="Date" time="true" format="Y-m-d H:i:s" divider-before="Publishing" />">
<perch:blog id="postDateTime" type="date" time="true" format="%d %B %Y" />
</time>
@husseinalhammad
husseinalhammad / find_or_create_collection_item.php
Last active October 5, 2021 13:48
Perch Import API - find_or_create_collection_item()
<?php
/**
* Find a Collection Item by a field. If not exists, create new.
*
* @param string $collectionKey
* @param string $template
* @param array $field $field = ['id' => '', 'value' => '']
* @param array $data
* @param boolean $return_item set to true to return item instead of _id
*
@husseinalhammad
husseinalhammad / dashboard.php
Created July 21, 2018 12:31
Perch Members - dashboard widget example
<?php
return function(){
$API = new PerchAPI(1, 'perch_members');
$Members = new PerchMembers_Members($API);
$HTML = $API->get('HTML');
$Lang = $API->get('Lang');
$Paging = $API->get('Paging');
$Paging->set_per_page(10);
$members = $Members->all($Paging);