web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / Web Template Extend | ...
Power Pages
Unanswered

Web Template Extend | Using Variable

(0) ShareShare
ReportReport
Posted on by 37

Hi,

I have a variable defined in my header web template called contentPageTemplate 

 

{% assign contentPageTemplate = "Help-Content" %}

 

I have the following content template applied to my page and am wanting to use the variable defined in my header for use in the extends definition; but cannot get this to work.

 

{% extends contentPageTemplate %}
{% block main %}
 This is my page
{% endblock %}

 

Any ideas how this could be achieved?

Thanks,

Categories:
I have the same question (0)
  • oliver.rodrigues Profile Picture
    9,368 Most Valuable Professional on at

    It might be the way you are using the extend Liquid tag, so basically:

    • The extend tag allows you to re-use an existing template, and overwrite content from the block you are specifying
    • You can reuse variables created on previous templates 

    For example, I am creating a simple liquid variable in the Header Web Template, and putting the content inside a block main:

    OliverRodrigues_1-1645723040363.png

     

    • Now I am creating a test web page/ web template and extending the Header, overwriting the main block:

    OliverRodrigues_2-1645723249752.png

     

    • this is my final result:

     

    OliverRodrigues_0-1645722966548.png

     

    so basically you don't extend a variable, you extend the entire Web Template, and the block is replaced with whatever you are extending

    give us more details of your scenario, perhaps there is another way of achieving what you need 

     

  • Christian Leverenz Profile Picture
    1,214 on at

    Hi @Gwham ,

    go for @OliverRodrigues advice. This will definitely work.

     

    Just to add one remark: you mentioned, that you define the variable in the header. Usually, you do not extend the header so the definititionplace is not the best one there. 

    May be using

    {% include 'valiabledecalrationtemplate' %}

    where the valiabledecalrationtemplate just contains your variabledefinitions as well in the header and in the template where the variable is needed is a better fit.

     

    Hope it inspires you for a solution,

      Christian

  • g.whammond Profile Picture
    37 on at

    @OliverRodriguesThank you for your response.

    Let's say I have 1000 web templates extending 'Header'.

     

    {% extends "Header" %}

     

    I want to update all 1000 web templates to now extend my newly created 'Oliver-Header' instead.

     

    {% extends "Oliver-Header" %}

     

    The problem I am having is i am manually having to go through each of the 1000 templates to update this one line

    I had hoped to be able to use a variable which had been defined in the header or somewhere similar.

     

    {% extends MyVariable %}

     

     

    @chleverenzI have a web template called 'Configuration' which contains all the 'global' variables I need throughout my portal which is referenced from the header. If this is what you are suggesting I already have this which means we are on the same page.

     

     


  • oliver.rodrigues Profile Picture
    9,368 Most Valuable Professional on at

    "I have a web template called 'Configuration' which contains all the 'global' variables I need throughout my portal which is referenced from the header"

     

    maybe you should be using Site Settings instead? Available Liquid objects - Power Apps | Microsoft Docs

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Pages

#1
Fubar Profile Picture

Fubar 70 Super User 2025 Season 2

#2
Jerry-IN Profile Picture

Jerry-IN 55

#3
sannavajjala87 Profile Picture

sannavajjala87 31

Last 30 days Overall leaderboard