Skip to main content

Questions tagged [globals]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
2 answers
25 views

Need help locating where global code is managed (for chatbot updating) on Craft CMS 3.4.30

We are trying to update our chatbot, and as someone who wasn't here when the Craft site was set up, I can't find where the current code is located. I feel like I checked all of the logical places, but ...
Ryan O'Connor's user avatar
1 vote
1 answer
58 views

Looking to simplify this if else. Any tips to make this simpler?

This is my first post here. Is this a softball question? How could I simplify the following code in twig? I've placed the controls for having popUp Modal windows in Globals rather than put these ...
Dwayne Jamieson's user avatar
1 vote
2 answers
123 views

Querying Globals from a Custom Field Type gives 502 Bad Gateaway

I'm creating a Custom Field Type whose possible values depend on the Globals. Therefore, I'm querying the Globals from the Custom Field's init(): class CustomField extends Checkboxes { public ...
Roman Sobkuliak's user avatar
0 votes
0 answers
48 views

Globals page not working for admin login only

When I click on my 'Globals' in my control panel area I get "This page isn't working, ERR_TOO_MANY_REDIRECTS." However only that admin user login has the issue, others team users access '...
Miller Enterprise's user avatar
1 vote
2 answers
603 views

Can I define and use global variables within content fields?

I'd like to set a variable like "totalCustomers" and then use this throughout our content in different pages and content blocks so that there is one source of truth. Is that possible? e.g. I ...
Lee's user avatar
  • 173
1 vote
2 answers
285 views

Globals disappeared/Queue Failed — Propagating global sets

In desperate need of some help! I noticed on one of my multi-sites, 5 out of 8 sites have items missing in the Globals sidebar.. When I manually type in the URL to view one of the global items I get: ...
fbnntt's user avatar
  • 109
2 votes
1 answer
635 views

Get global variable value PHP

In twig, I can get the value this way, globalWebsite.freeTrialPeriodDays I need to get this value in PHP, but cleary this won't work; $trialDays = \Craft::$app->getGlobals()->getSetByHandle('...
Sylvain Tremblay's user avatar
0 votes
0 answers
38 views

Troubleshooting General Slowness?

We have a Global page that has about 10 tabs with a bunch of fields each. The thing takes between 50 and 80 seconds to load. The debugger shows that it fires off over 9000 events and makes almost 900 ...
Tony DeStefano's user avatar
1 vote
1 answer
183 views

How to directly access translated variables by language

I have a localized, two language site (en and fr) that I have a translated global variable set for. My question is: is there a way on a Craft 3 template to directly access a translation of a variable ...
Stabilimenta's user avatar
2 votes
0 answers
150 views

Manipulating globals for multi-site?

I'm working on one Craft project with two sites (which have one shared page that is translated and possibly more in the future.) Is there a way to make the global header & footer for Site 2 ...
A Lemon's user avatar
  • 21
1 vote
1 answer
501 views

How do I get the siteName in a module (Craft 3)

In templates I can do something like {{siteName}}. But how do I retrieve this in a module? I've tried: Craft::$app->config->siteName I can grab my custom globals via Craft::$app->globals, but ...
Cat Named Dog's user avatar
0 votes
0 answers
238 views

Error when setting field length on global

I have set up several globals to store the URLs of a company’s social media accounts. Each one is a plain text field, and each one is limited to 254 characters. This works fine with three of them, but ...
mitrol's user avatar
  • 274
2 votes
2 answers
1k views

Is there a way to eager-load fields in a global set?

I use a header global set to store various thing about my site header, including the company's logo. I use it in my template like this: {{ header.globalSetsHeaderLogo.one()logo.getImg() }} Any idea ...
nstCactus's user avatar
  • 1,149
0 votes
1 answer
207 views

Accessing global field values in site loop

I have a drop down select that I am populating with sites. I've added a lightswitch field (handle 'showInDropDown') to the global set 'siteInfo' with the hope of getting the lightswitch value per site ...
joomkit's user avatar
  • 2,082
1 vote
1 answer
121 views

Show a list of pages but hide the current page from the list

My setup I'd like to show a navigation menu listing all my page entries. In my layout file, I include a template for the navigation: _layout.twig: <main> <section id="nav"> ...
gkpo's user avatar
  • 123
1 vote
1 answer
436 views

Use Craft globals for CSS styles

Is it possible to pass a value from Craft global setting into a CSS/SCSS file? So for example I want to be able to allow the end user to customise colours and fonts without having to include it inline....
Chrisl2310's user avatar
2 votes
1 answer
379 views

Updating global set from controller

This is my code: $giveaway = Craft::$app->globals->getSetByHandle('promotions'); $giveaway->giveawayName = "New Name"; $success = Craft::$app->globals->saveSet($giveaway); return($...
Lukigi's user avatar
  • 565
2 votes
2 answers
180 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), ...
Cat Named Dog's user avatar
1 vote
1 answer
137 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|...
Vaughn D. Taylor's user avatar
1 vote
0 answers
357 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 ...
Marcc1213's user avatar
1 vote
1 answer
106 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 = "{{ ...
Justyna Zygmunt's user avatar
1 vote
1 answer
157 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'...
Dr_Codswallop's user avatar
1 vote
1 answer
242 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, ...
Matt's user avatar
  • 13
1 vote
1 answer
57 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 ...
Dominik Krulak's user avatar
1 vote
1 answer
62 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 ...
Terry Upton's user avatar
  • 1,894
1 vote
1 answer
981 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?
Soldiers Wish's user avatar
1 vote
1 answer
510 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 ...
user2569's user avatar
  • 457
2 votes
1 answer
375 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|...
Dominik Krulak's user avatar
0 votes
1 answer
100 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?
Vitor's user avatar
  • 25
3 votes
1 answer
816 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 ...
cballenar's user avatar
  • 1,419
1 vote
1 answer
495 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. ...
Jan's user avatar
  • 196
1 vote
1 answer
376 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?
Mark Notton's user avatar
  • 2,347
1 vote
2 answers
894 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 ...
Malte's user avatar
  • 215
1 vote
1 answer
296 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 ...
joep's user avatar
  • 610
3 votes
1 answer
318 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 {{ ...
plg's user avatar
  • 43
1 vote
2 answers
341 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 ...
Stephen's user avatar
  • 695
1 vote
1 answer
81 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 ...
tom's user avatar
  • 465
2 votes
1 answer
38 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 ...
afc's user avatar
  • 67
5 votes
0 answers
226 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 ...
Chris's user avatar
  • 51
4 votes
1 answer
624 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....
Johan Douma's user avatar
2 votes
1 answer
224 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) ...
Moshe's user avatar
  • 135
0 votes
1 answer
69 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.
Moshe's user avatar
  • 135
1 vote
1 answer
123 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" ...
Terry Upton's user avatar
  • 1,894
0 votes
0 answers
54 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 ...
Adam McCombs's user avatar
  • 1,695
0 votes
2 answers
3k 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 ...
CreateSean's user avatar
  • 1,983
4 votes
1 answer
616 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 ...
Mark Notton's user avatar
  • 2,347
1 vote
1 answer
461 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> : ...
Bram B's user avatar
  • 353
3 votes
2 answers
322 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 ...
Mike Vaux's user avatar
  • 480
2 votes
2 answers
296 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 ...
FortySeven Media's user avatar
2 votes
1 answer
1k 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?
Brandon Kelly's user avatar