Blog

Thoughts, opinions and day-to-day ramblings

Manual import into Perch blog

Following on from the re-indexing post, here is some code we've used to create blog post entries within Perch CMS

include('perch/runtime.php'); 
$API = new PerchAPI(1.0, 'perch_blog');
$Posts = new PerchBlog_Posts($API);
$Template = $API->get('Template');
$Template->set('blog/post.html', 'blog');
$post['postTitle'] = "TEST POST";
$post['postDateTime'] = date('Y-m-d H:i:s');
$post['postStatus'] = 'Draft';
$post['postDescRaw'] = "Stuff\nMore stuff";
$post['postDescHTML'] = "

Stuff

More stuff

"; // JSON encoded fields $fields=array(); $fields['excerpt']['raw'] = "This is the excerpt"; $fields['excerpt']['processed'] = "

This is the excerpt

"; $fields['image']['_default'] = "/perch/resources/june14-1.jpg"; $fields['image']['path'] = basename("/perch/resources/june14-1.jpg"); $fields['image']['bucket'] = "default"; $fields['image']['sizes']['thumb']['w'] = 100; $fields['image']['sizes']['thumb']['path'] = $fields['image']['path']; $fields['image']['sizes']['thumb']['mime'] = "image\/jpeg"; $post['postDynamicFields'] = PerchUtil::json_safe_encode($fields); $Post = $Posts->create($post, $Template); $Post->index();

Hopefully the above may be useful to someone else

Published

Meet Rob & Jason

The Founders of Dev Partners

Dev Partners was founded by Rob Sherwood and Jason Wheeler to help businesses solve real-world problems with smarter software. With decades of combined experience — from media and publishing to aviation and eCommerce — we’ve seen how messy systems can hold companies back.

Our mission is simple: cut through the noise, analyse your processes, and build software that actually fits the way you work. When you work with Dev Partners, you work directly with us — no layers of account managers, just two founders who care about getting it right.

Read our Story
Rob & Jason - Founders of Dev Partners Ltd

Book a Free Consultation

Your enquiry comes straight to Rob & Jason - we’ll reply within one business day.


Dev Partners takes your privacy seriously and data will only be used for providing a quote for custom software. For more info see our privacy policy

Our Clients

A selection of the clients and brands we work with