I want to create a gallery page that each thumbnail is linked to a page describing the item for sale with a text field for the price. Is there a way to update that price text field site wide to say reduce all prices by 10%?
It sounds like a Global might be just what you need. You could create a reusable component — for example, a thumbnail image with a price — and then use that Global throughout your entire site. Any updates made to the Global will reflect everywhere it’s used.
Alternatively, you could create a Text component as a Global and use it solely for the price. That way, updating the price in one place updates it everywhere it appears.
We’re also in the process of building a set of CMS components that will allow you to manage and reuse data site-wide. You can check out this video for a sneak peek at how you’ll be able to create and reuse structured content across your project.
Of course, it all depends on your setup— are the prices the same across the site, or does each item have a unique price? Happy to help figure out the best approach based on your use case
Ben, are you sure a Global will work? The prices will be different for each item. Will I be able to tell the Global to reduce all the different prices by 10%?
Not directly — not if all the prices are different .
That’s why I mentioned earlier: “Are the prices the same across the site, or does each item have a unique price?” The solution depends on what you actually need.
That said, there are ways to achieve this using some custom code. For example, you could create a Custom Component— let’s call it Price — that dynamically calculates a discounted price using JavaScript or PHP.
You could set a global discount percentage like this using an @portal
, which injects content into a specific part of the page:
@portal("headEnd", includeOnce: true)
<script>
window.discountPercentage = 10;
</script>
@endportal
Then, inside your Price component, you could access window.discountPercentage
via JavaScript and use it to dynamically calculate and display the discounted price.
There are many ways to approach this — that’s just one idea off the top of my head
Thanks Ben. I will think about your Custom Component suggestion after I get my site designed. I bought Elements yesterday and I’m working my way through recreating my RW Classic site now.