Forum

Thread tagged as: Question

use perch_pages_title in region

Hi, Maybe a stupid question. But is it possible to use the perch_pages_title function in a region?

If not can i use perch:content id="landheading" from region "heroimages" in region "Reisorganisaties"? So a don't have to at the country name twice.

<perch:before>
<h2>Reisorganisaties <?php perch_pages_title(); ?> </h2>
<div class="reisorg_slider">
</perch:before>

    <div class="reisorg_item">  
        <div class="logoreisorg">
            <a href="https://<perch:content id="url_reisorg" type="text" label="Link naar aanbieder" replace="https://|" />" rel="nofollow" target="_blank" onclick="trackOutboundLink('<perch:content id="url_reisorg">'); return false;"> 
                <img src="<perch:content type="image" id="logo_reisorg" label="Image" bucket="logo_reisorg" height="130" />" alt="<perch:content type="text" id="alt" label="Alt tekst image, vul naam reisorg in" required="true" title="true" />" >
            </a>
        </div>

        <div class="hidden">
            <div 
                class="title"><perch:content id="naam_reisorg" type="text" label="Naam reisorganisatie" required="true" title="true" />
            </div>

            <div 
                class="long"><perch:content id="beschrijving_reisorg" type="textarea"label="Beschrijving reisorganisatie" html="true" editor="ckeditor" size="m" />
            </div>
        </div>              
    </div>

    <perch:after>
</div>
    </perch:after>
Fleur Besters

Fleur Besters 0 points

  • 3 years ago

You can just pass it into template like this

PerchSystem::set_var(‘title’, perch_pages_title())

https://docs.grabaperch.com/templates/passing-variables-into-templates/

Thx for your answer,

I try to use it but it dont't work.

Where do i put

PerchSystem::set_var(‘title’, perch_pages_title())

In template/content/reisorganisaties.html

Or in template/pages/land.php

This are the to files i use

<!doctype html>
<html lang="nl-NL">

<head>  
    <?php perch_content('google_analytics.html'); ?>
    <meta name="robots" content="noindex, nofollow" />
    <meta name="robots" content="none" />
    <meta name="charset" content="UTF-8" />
    <meta name='author' content='Reisbijbel'/>
    <meta name='viewport' content='width=device-width, initial-scale=1.0'/>

        <?php perch_page_attributes(array(
            'template'=>'seo.html'
        ));
        ?>

        <?php perch_page_attributes(array(
            'template'=>'headlink.html'
        ));
        ?>

    <title><?php perch_pages_title(); ?> Reizen en Vakantie - Reisinformatie - Reisbijbel</title>



</head>

<body class="<?php perch_page_attribute('bodyclass',array(
    'template'=>'body_attributes_land.html'
    ));
    ?>">



 <?php PerchUtil::output_debug(); ?>

    <div id="wrapper">
      <div id="navigation-menu">
          <div id="logo">
             <a class="reisbijbel-logo" href="/"><img width="350" height="98" src="/static/images/logo.svg" alt="Reisbijbel"/></a>
           </div>

            <div id="pagina-menu">
              <button id="factblocklink" value="facts"><?php perch_pages_title(); ?></button>
              <button id="tipsblocklink" value="tips">Tips</button>
              <button id="landitemslink" value="artikelen">Artikelen</button>
              <button id="reisorganisatieslink" value="reisorganisaties">reisorganisaties</button>
              <button id="reizenlink" value="reisorganisaties">Reizen</button>
            </div>

            <div id="menu">

                <div id="overons">
                  <a class="about-us-link" href="#">Over ons</a>
                </div>

                <div id="social-sharing">
                    <a target="_blank" href="https://twitter.com/reisbijbel"><i class="fa fa-twitter-square"></i></a>
                    <a target="_blank" href="https://www.facebook.com/reisbijbel/"><i class="fa fa-facebook-square"></i></a>
                    <a target="_blank" href="https://www.instagram.com/reisbijbel/"><i class="fa fa-instagram"></i></a>
                    <a target="_blank" href="https://www.youtube.com/user/Reisbijbel"><i class="fa fa-youtube-square"></i></a>
                </div>


                <div id="bestemmingen">

                    <a href="#" class="bestemming-btn overlay-destinations-link">

                        <div class="icon">
                            <div class="em flaticon-bestemmingen"></div>
                        </div>

                        <div class="tekst">
                            Onze reisbestemmingen
                        </div>
                    </a>
                </div>
            </div>
        </div>


        <div class="block-container">
            <!-- begin land hero image block -->
            <?php perch_content('heroimage.html'); ?>
            <!-- begin land facts  -->

            <div id="landfacts" class="introblock block-colour">     
                <?php perch_content('Facts_land'); ?>
            </div>

            <!-- parallax block 1  -->
            <div id="parallax1" class="bcg-parallax">
                <?php perch_content('parallax_quote.html'); ?>
            </div>
            <!--  parallax block   -->

            <!-- Hoogtepunten/tips/vliegtickets block -->
            <div class="block block-white" id="land-tips">

                <div id="bezienswaardigheden">
                    <div class="wrapper_bezientips">
                        <icon><i class="icon flaticon-place4"></i></icon>
                        <label class="article-label">Hoogtepunt</label>
                        <ondertitel><h2  class="article-author">Zien in <?php perch_pages_title(); ?></h2></ondertitel>
                    </div>
                    <?php perch_content('Hoogtepunten'); ?>
                </div>

                <div id="vliegtickets">
                    <div class="wrapper_bezientips">
                        <icon><i class="icon flaticon-plane15"></i></icon>
                        <label class="article-label">Vliegtickets</label>
                        <ondertitel><h2  class="article-author">Vluchten naar <?php perch_pages_title(); ?></h2></ondertitel>
                    </div>
                    <?php perch_content('vliegticket'); ?>
                </div>

                <div id="reistips">
                    <div class="wrapper_bezientips">
                        <icon><i class="icon flaticon-info"></i></icon>
                        <label class="article-label">Reistips</label>
                        <ondertitel><h2  class="article-author">Beste reistips <?php perch_pages_title(); ?></h2></ondertitel>
                    </div>

                 <?php                   
                perch_blog_custom(array(
                'tag'        => perch_pages_title(true),
                'section'   => 'reistips',
                'count'      => 5,
                'template'   => 'reistips_land.html',
                'sort'       => 'postDateTime',
                'sort-order' => 'DESC',
                ));
                ?>

                </div>   
            </div>
            <!-- Einde Hoogtepunten/tips/vliegtickets block -->


            <!-- Quote 2 -->
            <div id="parallax2" class="bcg-parallax">
                <?php perch_content('parallax_quote2.html'); ?>
            </div>
            <!--  Einde Quote 2 -->

            <!-- Landitems -->

            <div class="block block-white" id="block_landitems">
                <div class="itemsslider">
                 <?php                   
                perch_blog_custom(array(
                'tag'        => perch_pages_title(true),
                'count'      => 100,
                'template'   => 'items_land_slider.html',
                'sort'       => 'postDateTime',
                'sort-order' => 'DESC',
                ));
                ?>
                </div>
                <div class="article-content hidden"></div>
            </div>

            <!-- Reisorganisaties -->
            <div class="block block-white" id="reisorganisaties">
                <?php perch_content('reisorganisaties.html'); ?>
            </div>

            <!-- Reizen naar -->
            <div class="block block-green" id="reizen">
                <h2>Reizen naar <?php perch_pages_title(); ?> </h2>
                <div class="reizen_slider">
                 <?php      
                     perch_collection('Datafeeds', [
                    'filter' => 'datafeedland',
                    'match' => 'eq',
                    'value' => perch_pages_title(true),                 
                     'count' => 10,
                     'sort'  => '_date', 
                     'sort-order' => 'DESC',
                     ]);
                    ?>  
                </div>      
            </div>
             <!-- Einde Reizen naar -->
        </div>
    </div>   
    <div id="menu_klein">
        <!-- This checkbox will give us the toggle behavior, it will be hidden, but functional -->
        <input id="toggle" type="checkbox">

        <!-- IMPORTANT: Any element that we want to modify when the checkbox state changes go here, being "sibling" of the checkbox element -->

        <!-- This label is tied to the checkbox, and it will contain the toggle "buttons" -->
        <label class="toggle-container" for="toggle">
            <!-- If menu is open, it will be the "X" icon, otherwise just a clickable area behind the hamburger menu icon -->
            <span class="button button-toggle"></span>
        </label>

        <!-- The nav menu -->
        <nav class="nav">
            <a class="nav-item" href="">Dashboard</a>
            <a class="nav-item" href="">History</a>
            <a class="nav-item" href="">Statistics</a>
            <a class="nav-item" href="">Settings</a>
        </nav>
    </div>

    <?php perch_page_attributes(array(
        'template'=>'scripts.html'
        ));
    ?>

    <script type="text/javascript" src="/static/js/controls/animaties.js"></script>


</body>
</html>

And the region template

<perch:before>
<h2>Reisorganisaties <PerchSystem::set_var(‘title’, perch_pages_title()) /> </h2>
<div class="reisorg_slider">
</perch:before>

    <div class="reisorg_item">  
        <div class="logoreisorg">
            <a href="https://<perch:content id="url_reisorg" type="text" label="Link naar aanbieder" replace="https://|" />" rel="nofollow" target="_blank" onclick="trackOutboundLink('<perch:content id="url_reisorg">'); return false;"> 
                <img src="<perch:content type="image" id="logo_reisorg" label="Image" bucket="logo_reisorg" height="130" />" alt="<perch:content type="text" id="alt" label="Alt tekst image, vul naam reisorg in" required="true" title="true" />" >
            </a>
        </div>

        <div class="hidden">
            <div 
                class="title"><perch:content id="naam_reisorg" type="text" label="Naam reisorganisatie" required="true" title="true" />
            </div>

            <div 
                class="long"><perch:content id="beschrijving_reisorg" type="textarea"label="Beschrijving reisorganisatie" html="true" editor="ckeditor" size="m" />
            </div>
        </div>              
    </div>

    <perch:after>
</div>
    </perch:after>

What I gave you is .php code, so you would place it in your .php file, but it must be placed before the region. Also you will need to use perch_content_custom() in place of perch_content(). Last you need to add the hidden tag to your template where you want this output.

I think I provided a link to documentation?

:)