Posts by ellimondo

    Hi Claus


    Perch won't be able to tell what your CSS is doing to the html. But you can create multiple images from the one image when it is initially uploaded by just using the same ID on multiple tags.


    E.g. The following will output three images with different sizes, all with the same ID. You then just use the different sizes in your template where appropriate. The srcset and sizes options available to the image tag can do this for you without you having to use <perch:if> conditionals. Image options in the Perch docs are here.


    <perch:content id="image" type="image" label="Bild" width="100">

    <perch:content id="image" type="image" label="Bild" width="400">

    <perch:content id="image" type="image" label="Bild" width="800">


    You can use suppress="true" or suppress to stop a field appearing in your template. However, a lot of people use two templates with things like collections. One to use as an edit form in the CMS, and the second to display fields on a webpage. I find it's a much cleaner method of working.


    As to the caption, it's not possible to use the asset title. If you think about it the CMS is creating several files from your original upload so which one would it use? I would recommend you just add the caption as a separate text field to the form.

    Ah yes, sorry, I cut it off as I thought the beginning was the relevant bit.


    I've solved this by concatenating the import item's date and time fields and using the resulting variable.

    Code
    1. $session_start = $item['Date'] . ' ' . $item['Session Start'];
    2. $session_end = $item['Date'] . ' ' . $item['Session Finish'];
    3. $Importer->add_item([
    4. 'seminar_start' => $session_start,
    5. 'seminar_end' => $session_end,
    6. ]);

    The API importer requires an ID to match up related collections.


    The client is supplying the import csv file, so I can't expect them to know the IDs to the related items. I want to use the title instead (for instance).


    I want to check each item's title against the collection, match the ID and then pass it into the importer.


    How would I go about making a query similar the following in an app using the API? I am completely new to this so please be gentle with me. Any help greatly appreciated.

    Code
    1. $dayid = perch_collection('day', [
    2. 'filter' => 'day_title',
    3. 'match' => 'eq',
    4. 'value' => $item('day'),
    5. ]);

    Hi


    I am building an importer script for collections. When the script hits this line of data:

    Code
    1. 'seminar_start' => '12:30:00',

    I get an error starting Fatal error: Uncaught Error: Call to a member function get_date() on null in


    The template is using the following field so just the time shows on the page:

    Code
    1. <perch:content id="seminar_start" label="Start time" type="time" format="H:i" native>

    The json in the db is "seminar_start":"13:20:00"


    I think that Perch is doing something clever to the time field, but I cannot work out the format I need to parse the time in, in order for the importer script to run correctly? Can anyone enlighten me please?

    Hi Lee


    It's not clear from your template how you are getting the project details on a per page basis, but you can use a filter to exclude the current project from the project listing.


    If you are using a list/detail method by using a slug in the URL, then you can filter the results using the project's slug as below:

    Code
    1. 'filter'=>'project_slug',
    2. 'match'=>'neq',
    3. 'value'=> perch_get('s'),

    Otherwise you would need to use another method to get the id of the current project being displayed and filter on that.

    Hi


    I can't say what's general practice but I think most people would use perch_page_attributes and perch_page_attributes_extend to call the details into a page template. The docs are here.


    It gets more a wee bit more complicated when you separate out your pages into headers. For that you will need the function perch_layout_var to pass data from your main page into your header that calls the page attributes. The docs are here.


    And then it gets more complicated still when you factor in list/detail pages, blogs and collections (in Perch Runway).


    Hussein Al Hammad has written a great post called list/detail and beyond which includes some great tips on displaying meta data when it gets a bit more involved. It's a method very similar to what I use too (mainly because I swiped it off him ;) ).


    The official docs are a little out of date but there's a good piece on open graph meta data here, which has some nuggets in there.


    There's also Ryan Gitting's Chirp app which helps optimise SEO – that might be of interest.


    Hopefully these resources will help you understand the functions that get data from the details tab into your pages.

    Hi


    I have three collections: Days, Theatres, Sessions. All of which are related to each other in the sessions collection.


    What I want to do is iterate through Days, then Theatres, then Sessions in order to output a calendar to pdf.


    I am trying to use nested 'each' function calls to do this.


    The problem is that the second collection in the loop 'Theatres' doesn't contain any reference to the 'Day' data so that I then cannot filter 'Sessions' by day using the $item variable.


    Is there any way to get a variable from the first collection into the third collection call?


    I've got it working by manually creating a set of collection data for each day by setting the 'day.day_title' filter manually (there are only 2 days at the moment) but it would be great to automate the whole thing in the page template.