Perch ~ Passing variables into templates

I’m hoping someone here has worked with Perch and with a more php dev background help me get my head round a Perch problem.

I’ve worked with Perch CMS and Freeway which generally is very good but certain areas without a full PHP developer background the Perch support/forum can be a bit lacking as they assume shall I say “you should know this” please go away attitude probably because the developers of Perch are way too busy and other users either don’t know or the devs don’t need to ask of be there. This really highlights how good the Freeway Forum is to all users no matter what level they are at.

Anyway getting to the problem…

The Events App out of the blocks does much what you need to however if you add using Event Categories it can only sort the current month by category. You can only Click next month by date to show all…

…/events/index.php?d=2015-03/

So you need…

…./events/index.php?d=2015-03&cat=mycat

To make it work. Fine so need to GET the cat variable off a URL for the events app into a Events Template I can do this with PHP but Perch no I need this is the Event templates…

They say to use…

<?php   
PerchSystem::set_var('lang', 'en');
perch_content_custom('My region', array(        
'template'=>'template.html'
));
?>

Then in your template:

<a href="/<perch:content id="lang" />/contact/">Contact Us</a>

I can’t seem to get this to work probably because I need a breakdown as to what this first part of the code is doing. To me this is just manually setting a variable in the page is that right? Or can ‘en’ be ‘cat’ from the URL and naming it lang?

Also the Perch Events app does not have a region to put in My Region does it? Event is an app not general content

Have anyone worked with Perch to this extent?

David Owen


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

I had to do something vaguely similar with Events a few years ago for a now defunct site. I can’t recall specifics at this point but I’ll see if I still have the code from that job lying around. No promises.

Although the syntax is different this feels kind of similar to how I filter terms by passing them to another page for processing, albeit in a different CMS.

Todd
https://squinkd.us
https://xiiro.com


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Thanks Todd,

Did you find anything?

David Owen

On 24 Feb 2015, at 17:36, Todd email@hidden wrote:

I had to do something vaguely similar with Events a few years ago for a now defunct site. I can’t recall specifics at this point but I’ll see if I still have the code from that job lying around. No promises.

Although the syntax is different this feels kind of similar to how I filter terms by passing them to another page for processing, albeit in a different CMS.

Todd
https://squinkd.us
https://xiiro.com


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Sorry I should have updated this in case anyone else needs it…

You need the “true” to make it work which is where I was tripping up.

<?php

// get perch stuff in my php variable to use elsewhere

$myvar = perch_content_custom(‘My Region', array(
		 'page' => ‘/page.php',
               'template' => template.html',
), true); 

echo $myvar;

?>

Which means you can output any or all the input fields you need for further processing in your php app. Leaving Perch to do most of the heavy lifting of collecting and sorting information. Lovely!

David Owen

On 24 Feb 2015, at 15:50, David Owen email@hidden wrote:

I’m hoping someone here has worked with Perch and with a more php dev background help me get my head round a Perch problem.


freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options