1

How do I use/call globals in entries? Trying to insert a simple global called {{ whateveryounameit }} with some text but don't see anything except its name.

Any other ways to display common content across multiple entries?

4

You call globals with the globals' handle, and the field name of a field in it. So, if you have a text input field named "myField" inside a global with handle "myGlobal", you can call it anywhere in your templates with:

{{ myGlobal.myField }}
| improve this answer | |
  • Thanks but none of your solutions works for me. I'm trying to call globals within an entry not in the template and the related entries approach is too complicated and not really what I'm looking for. Any other ideas? – Mark H. Aug 28 '14 at 0:08
  • I'm confused? What do you mean "within an entry"? In the control panel? You can't put anything inside an entry since an entry isn't... anything. Do you mean that you want to use the value of a global inside a text input field in an entry, or something? – André Elvan Aug 28 '14 at 7:29
1

if globals don't work for you could create a related entry field that allows you call up previously created content (related blog or news posts as an example). This way you can but reference the same content through multiple entries but only have to create it once.

Here's the Craft docs for Relations

| improve this answer | |
  • Could you expand on how this would work? I have created a matrix block I use on a parent page, but now want to have exactly the same block on each child page. I don't want to hardcode, but I don't want to make the user have to add it for each child page. – Sebastian Thomas Aug 26 '15 at 11:29
  • Only way to do it would be to separate that matrix field and create it as it's only channel. Then inside whatever secondary entry, create a relationship field that points to that particular matrix field/entry. You'll end up isolating your content but you can use the same content in multiple locations. – Adam McCombs Aug 27 '15 at 1:31
1

The answer is detailed here: Reference tags inside Matrix textfield

You'll need to use the global set's element ID as the reference part (second segment) of the reference tag:

{globalset:51:siteUrl}

To find the global set's ID, go to CP -> Settings -> Globals. The URL to the global set will have the ID as the last segment (e.g. http://yoursite.craft.dev/admin/settings/globals/51)

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.