Questions tagged [templating]

Front-end Twig templates that can Craftily render markup, scripts, and styles.

Filter by
Sorted by
Tagged with
0
votes
0answers
8 views

ImagerX Connection Refused on Craft Nitro

I've currently got a website setup with Craft Nitro, though when trying to query an ImagerX image I get the following error: cURL error “7” encountered while attempting to download “http://xxxxx....
1
vote
1answer
12 views

Asset Custom Field Returning Null in Array

I am relatively new to Craft CMS and I have encountered an issue that I have attempted to debug for quite some time. When using the {% dd %} function to dump my array, a load of my custom fields ...
1
vote
1answer
23 views

Bad Gateway when using cached category query

I'm trying to find all tiers that have associated entries for a selection dropdown. This does not work, and throws a 502 error {% set allTeirs = craft.categories.group('catPartnerTeirs') %} {% set ...
1
vote
1answer
27 views

How to find next sibling from entry order of parent entries field

I have an index of projects that uses a standard entries field to select multiple entries to display and also provides a custom order (different to their Structure order). This is my "Projects&...
1
vote
1answer
26 views

Replace HTML string in body tag?

I have thousands of imported entries which have HTML image embeds to files which no longer exist. Is there a way to use the replace function in the tag to say replace <img src="[variable ...
-1
votes
1answer
66 views

how to create a custom plugin if the user enables plugin settings then it will replace the website home page to my custom design? [duplicate]

I am trying to create a plugin if the user enables plugin settings then it will replace the homepage of the website with my custom designed template
1
vote
1answer
44 views

For loop to dynamically output field names

I have a set of fields: fieldName1 fieldName2 fieldName3 fieldName4 fieldName5 and I want to be able to create a for loop something like this: {% for i in 1..5 %} {% if entry.fieldName ~ i|length ...
3
votes
1answer
56 views

Is there a way to return all available (custom) variables in some kind of list?

As I'm still a total n00b in working with CraftCMS, so I hope to get some help from more experienced users :-) I followed every available tutorial (which are very clear and well written. Great job!) ...
1
vote
1answer
35 views

How to Create an Author Page?

I'm trying to understand the best or most common approach to creating unique author/user pages that list that user's blog entries. This question was helpful for how to process the results. However, I'...
0
votes
1answer
42 views

Want to use assets field my template settings in custom plugin craftcms

I am creating a plugin that is based on images the admin will upload some sort of images in plugin settings not sure how to creat image field setting in plugin
1
vote
1answer
26 views

Twig filter country_name in craft CMS

Craft CMS doesn't have TWIG filter country_name. Even by default country name filter package is not available in twig. We need to install the corresponding package. https://twig.symfony.com/doc/3.x/...
1
vote
1answer
29 views

Upgrading to 3.7.26 causes tempnam() error from twig's FilesystemCache.php

I am upgrading a Craft project that I have been neglecting for a little bit too long. I am upgrading to 3.7.26 from 3.4.25; on top of this, I am upgrading from PHP 7.1 to PHP 7.4. I'm also updating a ...
1
vote
1answer
34 views

Using UrlHelper from template or remove query string params when paginating?

I have an implementation of a pagination which uses fetch() to get a subset of the page (i.e the page listing and pagination links), so when switching pages it gets the new list, as well as the ...
0
votes
0answers
10 views

Custom GraphQL Resolver that utilizes the same craft function used in twig

I'm pretty new to Craft CMS or PHP for that matter. I have custom code that unfortunately can't be done with just GraphQL so I need to utilize the same functions used in a twig template, in a custom ...
1
vote
1answer
20 views

Craft 3 paginate not working when fetched with a controller

I'm loading a paginate via Craft::$app->getView()->renderTemplate(), this is being executed within a controller. But my pageInfo.nextUrl is now the url of my controller (/actions/controllername/...
0
votes
0answers
14 views

Entry Looping Template With Javascript and 500 Internal Server Error

I'm working with a looping mechanism in my Twig code that loops through entries and displays them for a kiosk type of application. The loop itself works for the most part, although after a few hrs, it ...
1
vote
1answer
23 views

Find attributes in an object

I have a craft project which I've inherited and I'm trying to make some minor changes. I don't know PHP, Craft, or Twig very well so forgive me if this is an XY problem. This website is a company ...
1
vote
1answer
24 views

Customizing Field Layout / UI element in Craft Control Panel

Maybe I don't understand well the usage of UI Element in Field Layout, but I would like to display something more 'jazzy' for the admin on his CP and I thought inserting a twig template in the page ...
1
vote
1answer
42 views

Remove red error lines in VS code for TWIG

I've come across this a few times in my code / and others. Basically - there is no error, this is valid syntax and works, but is there a way I can highlight this and tell VS code - this is ok, dont ...
1
vote
1answer
22 views

how to write db-commands on custom table (PHP syntax) inside twig file?

if i have a custom table (ct_table) and i have to use MySQLi commands on it using the PHP syntax, it won't work if i put the PHP snippets inside a twig file. So are there any tools or official methods ...
1
vote
2answers
46 views

Replace asterisk (*) with my own HTML in twig-templates

I'm working on a Craft CMS website and I need help with formatting the H1 tag. I would like to be able to easily outline some parts of the title, like in the example below. Ideally by adding an ...
2
votes
1answer
51 views

Get entry associated with current uri

If I am visiting /recipes/spaghetti which corresponds to an entry in a recipes entry type and the recipes/entry template, is there a way to directly get the current entry's data from within the ...
0
votes
0answers
58 views

Passing variables, and reading them, to Module template

I'm trying to pass an array to a module's twig template (on the front end). I have tried many solutions I've seen here, but I'm not able to read the passed variables inside the twig template. In my ...
1
vote
2answers
47 views

Unable to find the template

I know this question has been asked multiple times. I have read all the post on this topic, and craft's docs. But still, I haven't figure out what I'm doing wrong. I would really appreciate a hand ...
2
votes
2answers
204 views

Get array of titles instead of whole collection of entries' attributes

I know that to get the entries I can do: craft.entries.all() but instead of getting the whole collection of entries, I would like to get an array of titles from those entries (or any other field). ...
1
vote
2answers
21 views

OrderBy section when selecting multiple sections in entries query

When getting pages from multiple sections like so: {% set aboutNavigation = craft.entries .section(['about', 'newsIndex']) .all() %} How can I set order that the sections appear? So I want ...
1
vote
1answer
21 views

Output Matrix field within Channel

Very new to craft and hence sorry if this is very basic. I have created a service channel which contains some matrix fields. One for a list and one for button. My approach here may be wrong and hence ...
0
votes
1answer
48 views

Improve performance and element queries when used multiple times

So I am building a mega menu and a separate set of templates for mobile. Both use the same set of element queries, which query two larger sections for pages and hierarchy. I am seeing quite slow load ...
1
vote
1answer
34 views

Blog pages returning HTTP 404 – Not Found – yii\web\NotFoundHttpException Template not found: blog/_entry

I’ve followed Craft’s instructions to set up the blog: https://craftcms.com/docs/getting-started-tutorial/configure/section.html When I published my first article, it returned a 404 error – see here: ...
1
vote
1answer
34 views

How to get rules of conditional fields values on front-end, using Reasons or another solution?

I'm building a front-end form, where I'm displaying on front-end my fields following their layout within the CP: {% set section = craft.app.sections.getSectionByHandle('handle') %} {% set ...
1
vote
1answer
53 views

Template URL/path alias

Is there any way to use an environment variable in the URL and template path settings for sections? We are prototyping a site with a temporary skin running alongside our front-end build but would ...
0
votes
1answer
21 views

How to get field widths when using getFieldLayout()?

I'm trying to show all my Channel's fields on front end, as they are shown on the CP: {% set section = craft.app.sections.getSectionByHandle('handle') %} {% set fieldLayout = section.getEntryTypes[0]....
1
vote
1answer
40 views

Loading JavaScript on Template Load

I'm working on a kiosk-type plugin which will cycle through all news entries, beginning upon template (or page) load. It needs to load a JavaScript ajax script for this on page/template load. Would ...
2
votes
1answer
25 views

Sorting Categories/Entries by # of relations dynamically

does anyone know if there's a way to display a type of "most popular categories" list? It's not exactly my use-case, but it's very similar Essentially, I want to be able to have users search ...
1
vote
1answer
35 views

Navigation Menu Options - drop downs and sticky?

I'm new to Craft CMS. It is possible to create a navigation menu with drop down menu items and a sticky menu bar on the desktop view please? How/where do I do this please? (Using Craft 2.7.10) ...
1
vote
1answer
25 views

What's the best strategy for products that are sold?

I wonder what's best practice for products that are sold? My strategy is to add a lightswitch "sold" and don't display sold products on the website and in the sitemap.xml, in the hopes that ...
0
votes
1answer
57 views

Regular Expression replace not working within Twig Template

I'm attempting to capture 4 attributes of an Attributes of an tag and injecting inline styles to the style attribute. Craft CMS and Twig templates are being used to generate HTML emails here, hence ...
1
vote
1answer
81 views

How can I pass a variable to Freeform's formatting template so that it's available to Twig?

I want to be able to toggle the display of a form's Title on or off, without having to resort to using a mostly-identical copy of the formatting template. Freeform formatting template: {% if ...
1
vote
1answer
23 views

Showing and hiding details (price, sale price, sku etc)when product variant is selected on details page

I currently have price, sku and variant title swapping when clicking between variants on a products details page. This works with AlpineJS and looks something this. https://codepen.io/amasci/pen/...
-1
votes
1answer
56 views

Contact Form - Not sending emails

I am getting test emails but not contact form email? {% macro errorList(errors) %} {% if errors %} {{ ul(errors, {class: 'errors'}) }} {% endif %} {% endmacro %} {% set message = ...
1
vote
2answers
84 views

Merging classes in Twig based on component and context

Whats the best way to approach this in twig? So I have a component that is used in multiple places, so within this component I set some default classes like so: {% set navSidebarClasses = { heading: ...
1
vote
1answer
19 views

Creating a channel (or entries) using a similar channel

I am currently trying to make a channel called "classmates" similar to a channel that is called "News". I have this working beautifully, but I am not sure how to set a different ...
0
votes
0answers
28 views

Restrict Shipping Options to certain user groups - commerce

Craft 3.7.4 Craft Commerce Pro 3.4.0.3 Postie 2.4.8 I'm working on an inherited site which is my first using Commerce. I've been tasked with restricting shipping methods based on logged in user group ...
1
vote
1answer
25 views

Twig Template spits out jibberish when trying to access user-defined fields

I have an Entry called Groups (I'm wondering if this might be some sort of reserved word issue) and, with Twig, I can bring out the base fields of id and title with no issue but when I try to pull ...
1
vote
1answer
39 views

Decrease heading level if entry is descendant in Redactor

I am currently building a doc system with multiple levels. I have build individual entries, but I'd like to parse the whole documentation in one page. Currently, I'm doing it like this: {% set pages = ...
1
vote
1answer
91 views

Split string with multiple delimiters

Hi what is the best was to split a paragraph into sentences please? I can use: {{ content|split('.') }} but what if a sentence in the paragraph ends with a question mark or exclamation mark instead? ...
1
vote
1answer
19 views

in array not matching

I am probably doing something daft here, but tried multiple things to no resolution. I trying to find if a value is in an array but my test case doesn't match. {% if entry.applicationStatus == '...
1
vote
1answer
66 views

Debugging Craft CMS templates on Visual Studio Code

Is there a way to debug templates used in craft cms on visual studio code? I tried doing it but I just get this error: "${workspaceFolder}' can not be resolved. Please open a folder." Any ...
1
vote
3answers
131 views

CSS file not being read by other templates

So I am making a new craft cms website, I have my page entries linked to the template pages/_entry.html, which works fine. I then made another type of pages called news, linked to the template news/...
0
votes
0answers
56 views

Internal Server Error after upgrading from craftcms 2 to 3

I just upgraded from Craft 2 to 3.6.14 (latest). I was able to successfully to the upgrade. I am able to get into the admin and was even able to install the feed-me plugin. I ported over all the files ...

1
2 3 4 5
33