We’re rewarding the question askers & reputations are being recalculated! Read more.

Questions tagged [globals]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
2
votes
2answers
149 views

What is appropriate for a Global field in terms of site speed?

I'm worried that if I put too much in globals, I will impact the speed of my site by a lot. For example, I was thinking of putting content in there like matrices for team members (text and image), ...
0
votes
0answers
18 views

Possible to move matrix content from one global set to another

Is it possible within the database to manipulate a couple of keys to move matrix content to another global set without having to re-enter it all in Craft 3? I have the matrix field in both global ...
0
votes
0answers
19 views

Saving globals slow with lots of sites

I'm working on a craft site that has 188 locations. Each location has its own site. Normally I would create a channel entry for Locations, but each location (site) needs its own blog and pages. I ...
1
vote
1answer
20 views

Can I use a Global Variable for date/time?

The goal is to create a global variable that allows the user to specify how they would like to format the date/time for entries. I'd like to remove the hardcoded format shown here: {{ entry.postDate|...
1
vote
0answers
71 views

Craft 3 Cannot Save Global Set

I am playing around with Craft 3 and for the life of me cannot get it to save an element programmatically. I am trying to save a Global Set from a module like so: $config = [ 'name' => "My ...
1
vote
1answer
25 views

Access table from Globals in script

In the Globals I have a field which is of type table. I was trying to access this table in the javascript in order to get the values of particular rows. <script> var myTable = "{{ ...
1
vote
1answer
36 views

Translating checkbox labels

I'm trying to translate the labels for a global checkbox field in my front-end templates like in this post: Is there a way to have checkbox field labels translatable?. This looked promising but I can'...
1
vote
1answer
38 views

SEOmatic and Global Variables

We have a Craft site with nearly 800 entries. For SEO purposes we need to change the page title and page (SEO) description for each entry, a laborious task to say the least. Is there a way to have, ...
1
vote
1answer
23 views

Accessing global set's field gives object that couldn't be converted to string

I've been using globals many times but this is my first time encounter with such problem. Let's go from the bottom. I have two global sets with handles tax and company. The Tax set have only one plain ...
1
vote
1answer
33 views

How can I make related entries and globals part of the search considerations?

How can I make related entries and globals part of the search considerations? So I have a website search bar that searches the whole website. Within some jobs pages there are some global elements ...
1
vote
1answer
283 views

How to edit a global footer link

In the footer at the bottom of my page, www.soldierswish.org, there are two links for 501c3 and Form 990. Is there no way to edit these from the GUI? How do I edit these links?
1
vote
1answer
238 views

Getting image url from globals asset field

I can retrieve only the image title from the below code, I can't see why the image URL is showing as empty? its a global handle 'brand' and asset field 'logo': {% set image = brand.logo.one %} <a ...
2
votes
1answer
161 views

Comparing date field object with global variable “now” gives unexpected result

The goal is to show a word when date field qualifies for tomorrow or today instead of numeric date. Setting and calling variables: {% set deliveryDate = order.deliveryDate %} {% set tomorrow = now|...
0
votes
1answer
48 views

Global field duplicated

I have two sites. Everytime I add global field content (slogan for example) it adds the same to the second site, and vice-versa. Anyone has any idea how to stop that?
1
vote
1answer
264 views

Get globals from other sites

How would I get the global variables associated to other sites? For example, in an instance where I have three websites under the group languages for the English, Spanish, and French versions. I have ...
1
vote
1answer
229 views

Best practise to use translate in admin panel

I am using a lot of translation with the |t / |translate filter. But the client wants to be able to edit those translations in the admin panel. So, I thought about different ways to achieve that. ...
1
vote
1answer
211 views

Defining TwigExtension globals in Craft 3

A long time ago I asked how I could utilise the getGlobal method in Craft 2.x. I'd like to know how best to do this in Craft 3?
1
vote
2answers
355 views

Access global field content

What could be the reason for this error when I’m targeting a global field?: Impossible to access an attribute ("footer") on a boolean variable (""). I created a global set Footer with a matrix ...
1
vote
1answer
125 views

Saving fields to a GlobalSet

Can anyone suggest on how to programatically save fields to a GlobalSet? I’ve been following this: Programatically Adding Fields to a Layout But, doesn’t seem to work with a global? I am doing the ...
2
votes
1answer
238 views

Use Globals in email templates

I’ve set up a few email notifications to be sent to customers, and in the corresponding email templates I’d like to use content from Global fields I’ve created. But when I use the regular variable {{ ...
1
vote
1answer
163 views

Trying to set an image URL using a global asset field

I've setup a global asset field so that a client can change a placeholder image that gets used throughout their website. I'm using the Imager plugin for my image transforms. The following image code ...
1
vote
1answer
62 views

Globally share variables

I have 4 main template folders, under the /craft folder (each template folder works for another subdomain). Now, I do have per template folder, a few variables that I like to have shared amongst all ...
2
votes
1answer
33 views

I want to display entries that have a field that is the same as a field in a global variable

There is a publishMonth (multiselect) and publishYear (radio buttons) field in each article. They do not correspond to an actual date. Each article is is associated with one year, or one or more ...
4
votes
0answers
125 views

Eagerloading Matrix fields resulting in empty array

I'm trying to eager-load a Matrix field with it's blocktype and related field types. For some reason the _eagerLoadedBlockTypeElements are empty arrays. If I get rid of the with clause on ...
4
votes
1answer
463 views

Use global values in the Entry URL Format field

I'm trying to use global variables in Entry URLs generated by Craft, but they seem to be empty. Not getting any errors as such, just null. My Entry URL format looks like this: {{siteDefaults....
2
votes
1answer
146 views

Is There a Way to Add Tabs in Global Fields?

I see that it is not possible to add tabs to Global fields (unlike, say, with entries, where one can organize one's fields into different tab groups). Is there a way (without editing the core files) ...
0
votes
1answer
60 views

Is it Possible to Use Live Preview with Global Settings

I know that out of the box one cannot use Live Preview with Global Settings. I am wondering if it is possible to write a plugin or in some other manner get Live Preview to work with Global Settings.
1
vote
1answer
94 views

Order PDF in back-end error with Globals

I have created a PDF template for orders and this works fine on the front-end. However, when I click to Download PDF through the admin panel in an order. I get an error that: Variable "companyInfo" ...
0
votes
0answers
47 views

Custom Messages including variables in global field?

Is it possible to setup messages (for transactional emails) as global text fields that include variables such as {{ firstName }}, {{ lastName }}, {{ email }} etc.? For example: Custom plugin fires ...
0
votes
2answers
1k views

Create an Array in Twig and loop through fields in global set

So I've created a globals set (socialMedia) with 10 input fields, but this could grow in the future, for clients to add links to various social media accounts. This works fine except that the code for ...
4
votes
1answer
383 views

Does Twigs 'addGlobal' exist in Craft?

I know Craft gives us access to Twigs getTwig template service; so when I attempt to use the addGlobal function like so: craft()->templates->getTwig()->addGlobal('var', $var); ... nothing ...
1
vote
1answer
432 views

Failed to add a custom field in settings

I'm trying to add a global set, with a Matrix and two required fields for a product. This always works. Now that I am in version 2.6.2791 it fails to add the fields with error: Warning</b> : ...
3
votes
2answers
203 views

Best Method of Handling Repeated Content Within Existing Fields?

We are trying to find the best solution for handling repeated content within existing Fields in the CMS. That is, there are bits of information which could be used nearly anywhere within existing ...
2
votes
2answers
160 views

Using a Dropdown field in a Matrix to parse a global

I have two globals setup for affiliate and compensated type language - using Matrix and a dropdown I'm trying to find a way to let the user add this language in a new block. I cannot for the life of ...
2
votes
1answer
823 views

Accessing global sets from Element API

Is there an easy way to access global sets from an Element API endpoint, so its content can be included in the JSON response?
2
votes
1answer
507 views

How to get field values from Global Set using Element API plugin?

I'm pulling data from a Global Set using the Element API plugin and am wondering if there's a cleaner way to write the transformer function? My craft/config/elementapi.php file looks like this: <...
1
vote
1answer
105 views

How can I get a field's value from a global based on a url segment?

I have a rich text field with a handle of myTextField that I have included in a global set called firstGlobalSet. What If I created another global set called secondGlobalSet and included the same ...
1
vote
1answer
262 views

Update globals Matrix via a plugin

We are working on a plugin that needs to update the contents of a Matrix field within Globals. I've found little snippets of code but none that do exactly this. Can anyone provide some code or point ...
2
votes
2answers
164 views

Can I use isEditable() on a global?

I have a headline global. I am trying to see if headline is editable by using this code block, but it is not working. Can I use isEditable() with my headline global? {% if headline.isEditable() %} ...
3
votes
2answers
855 views

How to parse environment variables and globals from a field

I want the ability to parse environment variables such as {siteName} and globals from channel fields, for example a rich text field. I have been using {{ include(template_from_string(entry.fieldName)|...
2
votes
2answers
576 views

How do I check if a Global field exists in a template?

In a template, can I check whether a Global field exists, before I try to output its value? I want to ensure the page doesn't break entirely in the unlikely event of the field being removed from the ...
2
votes
1answer
580 views

Calling an Asset field from a Global

I can't, for the life of me, find an answer to this question. I have a global called work. It has three Asset fields. One is called mediakit, which is an upload of a PDF. I am trying to get the ...
5
votes
1answer
322 views

Globals versus Singles

We are building a restaurant site that has a banner image and some introductory text on each page. For pages that include content from a Channel, e.g. the wine list, we are using a Global to define ...
5
votes
3answers
3k views

How to retrieve Site Url and Site Name in Plugin

I'm having an exceedingly difficult time trying to retrieve the Site URL and Name in a custom plugin I am developing. My research has led me to believe this would work: $envVar = craft()->config-&...
0
votes
1answer
96 views

How can I populate a dropdown via Globals?

I have a registration form that has a dropdown that allows the user to choose a color. This form input will be the same across all pages that allow a user to register. So, I thought using a Global to ...
3
votes
1answer
308 views

Use Asset field as a Global Set Variable?

Is it possible to use an Asset field as a Global Set? For example: {{ companyInfo.logo }}
0
votes
1answer
380 views

Update Global Variables

I've got a custom plugin where I'm trying to update a global variable. The variable field type is of type Entry I'm getting the set using getSetByHandle then using getContent on the set. However, ...
3
votes
2answers
443 views

Find specific image from global image set?

I am using a global set to store image assets used across the site. I am not sure how to reference a specific image. I know how to get the image if its just one, using : {{ design.imgs | length ? ...
2
votes
1answer
464 views

Global Image Variables?

I have setup a global set for images i use across the site. I have one for seo - where I have images for a twitter card and Facebook image in my seo settings. There is only one image for each field ( ...
0
votes
1answer
504 views

Link to Global Fields like you can with the entries fieldtype

Is there any way to link to a global using a field in a entry form, much like you would use the "Entries" fieldtype to link to entries?