Insights, perspectives, and stories on software, business, and innovation.
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“Working with Dev Partners has been an exceptional experience from start to finish. Their team is highly skilled, professional, and committed to delivering top-quality results. Whether it was project management, software development, or technical support, they consistently demonstrated a strong understanding of our goals and went above and beyond to meet deadlines without compromising on quality. What truly sets Dev Partners apart is their communication and transparency. We always felt informed, supported, and confident in their process. Their ability to adapt to our evolving needs and provide creative, scalable solutions made a significant impact on our project's success. I would highly recommend Dev Partners to any business looking for a reliable, innovative, and client-focused development partner. They've earned our trust, and we look forward to future collaborations.”
If clunky systems are slowing you down, let’s talk. No sales patter. No corporate waffle. Just a straightforward conversation about fixing the stuff that wastes your time.
Two normal blokes who happen to be good at untangling messy systems. We’ll talk to you like humans, not consultants, and help you find the simplest way forward.
We’ll reply within one working day. No spam. No waffle.