Forum

Thread tagged as: Question

Using an one element from a template

Hi,

I have a template which have the id below:

<a href="<perch:content id="link" type="text" label="Link" markdown="true" editor="markitup" help="Indsæt det link presseklippet skal henvise til. Fx.: https://axcel.dk" />" class="white btn btn-default btn-padding" target="_blank">

I want to use the ID on another page called presseklip.php to list the ID's like this:

                <p>
                  List the ID
                </p>
                <p>
                  List the ID                  
                </p>
                <p>
                  List the ID                  
                </p>

Could you help me do this :)

Simon Rothenborg

Simon Rothenborg 0 points

  • 7 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Use perch_content_custom() to display content from one page on another.

perch_content_custom('Region name', array(
     'page' => '/presseklip.php';
     'template' => 'your_template.html',
));

Hi Drew.

Thanks for the answer.

If i do like this:

                <?php
                perch_content_custom('headline', array(
                    'page'=>'/presseklip.php',
                    'template' => 'presseklip.html',
                ));
                ?>

Nothing happens. Can i reuse just on ID instead for a whole region. My presseklip.html looks like this:

<div class="blogindlaeg">
    <h3><perch:content id="headline" type="text" label="Overskrift" markdown="false" editor="markitup" /></h3>

    <p class="datepress"><perch:content id="Dato" type="date" label="Dato" format="d-m-y" required="true" title="true" /></p>
    <p>
      <perch:content id="text" type="text" label="Tekst" markdown="false" editor="markitup" help="Teksten bliver beskåret efter 200 tegn"maxlength="200" /> ...
    </p>
    <perch:if exists="link">
     <a href="<perch:content id="link" type="text" label="Link" markdown="true" editor="markitup" help="Indsæt det link presseklippet skal henvise til. Fx.: https://axcel.dk" />" class="white btn btn-default btn-padding" target="_blank">Læs presseklippet</a>
     <perch:else />
         <a href="<perch:content id="file" type="file" label="File" markdown="true" editor="markitup" help="Hvis der skal henvises til en PDF fil i stedet for et link" />" class="white btn btn-default btn-padding" target="_blank">Download presseklippet</a>
    </perch:if>

</div>
Drew McLellan

Drew McLellan 2638 points
Perch Support

What do you mean by "nothing happens"?

It does not display anything :)

But if i change it to one of the regions, like this :

            <?php
            perch_content_custom('presseklip', array(
                'page'=>'/presseklip.php',
                'template' => 'presseklip.html',
            ));
            ?>

It displays the whole region

Drew McLellan

Drew McLellan 2638 points
Perch Support

Have you narrowed your template to only output the fields you want?

I got it. Thanks for your help