Questions tagged [templating]

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

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

How to develop API with TWIG

I want to develop an API within Twig template that will have PDO implementation to get data. My application will be using content through CRAFT. Is it possible to develop API with TWIG template? ...
1
vote
1answer
16 views

Issue on new craft (craftcms3) setups: vendor Twig can't read system variable

After installing craft through composer, setting up the database and running craft setup, I have a craft application ready to go. When I go to settings/general, I always get a crash with following ...
2
votes
1answer
25 views

Dynamic URI to load entry template

This may be asking the impossible, but I'm trying to do the following: Say I have 3 channels, Country, Region, and Town. Town has an entry field to select a Region, a Region entry has a field to ...
0
votes
0answers
32 views

Why aren't my images displayed on the homepage

Our homepage.twig is a section Our Matrix is called "angebote" (it's german don't ask :D) We created two entries for our matrix This is our Code inside the homepage.twig file for including ...
1
vote
1answer
20 views

Entries limited by date range

I'm trying to filter entries on the front end by a date range but no matter what I do I end up with no results, despite there being results in the, temporarily hard coded, date range I am using. {% ...
1
vote
1answer
20 views

Simple Product Listing Pages by Category Slug

I'm new to Craft and I'm trying to create very basic product listing pages based on Categories and I'm not sure where to start. First, it doesn't look to me like you can create separate templates for ...
1
vote
0answers
21 views

Creating a modal popup using CraftCMS and Twig

I've been looking everywhere, I'm trying to create a modal using a global but I can't seem to figure out where to start. JavaScript: $popUp = new Garnish.Modal($('#popUpModal('), $popUp.show(), $popUp....
1
vote
1answer
46 views

Custom sort order?

I have a page that displays musicians grouped by their musical instrument. I am outputting them grouped by instrument, but I have been asked to sort the instrument groups by a custom order specified ...
0
votes
1answer
17 views

Change order content blocks home page

Good afternoon, I was wondering to what extent you can change (the order for example) the existing contentblocks on the pages. Thank you in advance!
1
vote
1answer
15 views

How to get values into twig template for fields of type Matrix in Craft CMS 2?

CMS: Craft CMS 2 In my admin panel I have globals set called X (under "Globals" from the sidebar and defined in craft_globalsets in the db from Global->Settings->New global set). A ...
1
vote
1answer
16 views

Relative Asset URL

I'm looking to output the relative URL of my assets instead of the full URL with domain for my Imgix config. As imgix puts it in their docs: http://www.yourcompany.imgix.com/images/examples/pic.jpg ...
2
votes
1answer
72 views

How to include external JavaScript in place?

We include an external script from a vendor and the URL doesn't end in .js. It returns JavaScript that creates a widget in place. I was able to fake it out by adding a '&js=.js' parameter but it ...
1
vote
2answers
41 views

How to get an input value without refreshing with twig?

One way to read a dynamically inserted value is to refresh the page and get it in a twig variable through the url, something like this: {% set amount = craft.app.request.getQueryParam('amount') %} ...
1
vote
1answer
18 views

Getting an asset Url from an entry loop into a meta tag

I found it pretty straightforward to get something like dynamic page titles working by setting a variable at the template level and pulling that into my site's meta tags: My _layout.twig: <head> ...
0
votes
1answer
33 views

Getting blocks from matrix and injecting them throughout a page, NOT a single loop statement

I have a matrix field that allows the user to add little 'designed' features throughout the page. These are placed in certain positions on the page and so I want to loop through these but because they ...
0
votes
0answers
17 views

Freeform - Alternate Success Markup after AJAX Submit

Regarding Solspace Freeform: I want to have a custom message when submitting a form via AJAX. In the docs, there is some JS I used (see below). It works, but I want to know what to replace the code ...
1
vote
1answer
42 views

Is there any way to code multiple lines in a twig file?

Instead of using: {% ... %} {% ... %} {% ... %} For each line, i'd like to know if there is a way to do something like: {% ... ... ... %}
1
vote
0answers
14 views

Freeform output styling

When rendering the output of a single Star Rating field using the default Flexbox form, the output creates its own styling, overriding what I put in the element it's in... and adds a "float: left&...
1
vote
2answers
44 views

Dynamic Blitz Template not loading currentUser

I have a Dynamic Blitz template with a currentUser if statement within it. For some reason, it's not working and I can't figure out why. It gets loaded in as follows: {{ craft.blitz.getTemplate('...
0
votes
0answers
65 views

Help with picking the right template tactic: include, embed, use, macro

I've run up against the limits of includes and macros for the context before me and can't quite get my head round other options such as use and embed, which I've never had need to use before. I know ...
1
vote
1answer
11 views

Merge list of categories related to 'project' entries - not working, a solution

good to be back) Helping a friend out with a website for his tiling business. The site contains a 'projects' section which displays category-filter buttons allowing the user to toggle relevant ...
3
votes
2answers
36 views

Twig search function doesn't work after upgrading to Craft 3

My client's Craft 2 site includes several templates which use search functions to return a product entry by an ID, like so: {% set product = craft.entries.section('Product') .search('...
1
vote
1answer
77 views

Craft 3 - Twig search query for entry with custom EntriesField containing disabled entry

I have a search form with 1 simple input (q) I also have 2 sections: SECTION-A & SECTION-B The search is for entries within SECTION A. The entry I'm searching for contains a custom entriesField ...
1
vote
1answer
35 views

Adding entries to the top level scope of a variable in Twig

I have made a frontpage editing system where the user can desk a frontpage, adding news items and other blocks manually. One of the blocks is "Last n news items". I would like this to ...
1
vote
1answer
45 views

Filtering by lightswitch fields

Bit of an unusual one and sure must be missing something but know if we have a defined lightswitch field we want to filter against it can quite easily be done so like this: {{ craft.products().myField(...
1
vote
1answer
16 views

Is there a way to query for a list of values belonging to a specific field in a queryset?

For instance, if I wanted an array of all the titles belonging to a subset of entries that I wish to query. The way I know how to do this currently is like so: {% set titleList = [] %} {% ...
1
vote
2answers
38 views

Twig template outputting blank page on non-“dev” environment

I've created a base twig template which contains some basic "maintenance mode" logic. This works perfectly as long as the main ENVIRONMENT in the .env file is set as dev, but fails for ...
1
vote
1answer
27 views

localized site - except home, every page gives me a 404

I have a newly published site, where the localization does not work properly. https://www.nomadenschaetze.com/de/ When i switch to english, it shows the right englisch homoepage. Now, when i click ...
2
votes
1answer
48 views

Blitz Cache dynamic button

I have a Blitz Cache but the only bit of dynamic data on the page is a "Follow" button which changes depending on if you're following this entry. Looking at their docs, I don't see a way of ...
1
vote
1answer
121 views

Input and Use Twig Variable in External JS Script Across Different Pages

I have created a _layout.twig file which acts as my base to hold content on the page -> _layout.twig: <!DOCTYPE html> <html lang="{{ craft.app.language }}"> <head> ...
0
votes
0answers
31 views

Tons of Apache TWIG errors on Craft 3 website

I'm only getting these errors on a select few pages of my website after upgrading from Craft 2 to Craft 3: TypeError: Argument 1 passed to craft\web\twig\variables\CraftVariable::entries() must be of ...
1
vote
2answers
28 views

Matrix fields don't load!

I have some matrix fields defined: But when I use the matrix blocks inside of an entry - I don't get all blocks - just the richText ones. I tested it out - just the richtText Matrix blocks will be ...
1
vote
1answer
46 views

Grouping Super Table Results via Twig Multidimensional Array

I'm trying to loop through a Super Table array and group results based on a category ('contribution'). I've gotten pretty far but I'm struggling creating an array in Twig that gives me what I need (I ...
0
votes
0answers
12 views

Adding a specific field to search() parameter that contains an object

I'm currently running a search which contains an object {query:query, subLeft: true, subRight: true} {% set query = craft.request.getParam('q') %} {% set entries = craft.entries.section('example')....
0
votes
0answers
25 views

External GraphQL API support with Twig

I have external GraphQL API's to get data which will be used in Twig Templates. This has nothing to do with Craft data or Craft's content. Is there a way to call GraphQL from Twig template instead of ...
0
votes
0answers
22 views

Recognizing Twig tags in VS code live server

I'm not sure if this is the correct place to ask this, but seeing as I'm developing with Craft I thought I'd give it a try. Does anyone know if it's possible for the Live Server plugin for VS Code to ...
1
vote
2answers
44 views

{{ entry.image.first().url }} won't show image

I am on my first Craft CMS test site. Have some problems showing a simple image. <img src="{{ entry.hero.first().url }}" title="{{ hero.title }}"> I get the title but can't ...
1
vote
1answer
22 views

Null Length Error on Craft Version 3

I am not super fluent in Twig and I inherited a website from a company that built the site in Craft v2. The site was upgraded to version 3 of Craft recently and one of the template pages is throwing ...
1
vote
1answer
24 views

Simple way to create a slideshow with Twig and a for loop?

I have this code, which is basically a loop in a Twig template where I show opinions: <section class="opinions"> <h2 class="opinions__title heading2"> ...
0
votes
0answers
24 views

Similar plugin filter results by section

I currently have the Similar plugin on my system, and I'm looking for similar entries by Category. It's working great, but I'm looking to limit the results to a specific section. {% set ...
1
vote
1answer
23 views

Output of matrix field twice in one template

I have a matrix field with with multiple types. In a template I want to loop through all of the entries of that matrix field as you normally would. However, I also want to access a bit of data from a ...
1
vote
1answer
39 views

Get first X paragraphs, then output the rest

The below is code that works to only show the first paragraph, then show the rest. Is it possible to instead, show the first five or six paragraphs, then show the rest? {# Split paragraphs using a ...
0
votes
0answers
20 views

How can I get the dimensions of a video asset?

The video itself hasn't any dimensions (width and height) within its object. But Craft saves a thumbnail, right? How would I get to the thumbnail to get its width and height? Or is there something ...
1
vote
2answers
23 views

Limiting entries object when using as json_encode

I'm building a JSON array of several thousand entries using the following entries query: {% set services = craft.entries.section('services').asArray().all() %} The problem is there some private info ...
1
vote
1answer
24 views

Calling a setter via craft.app in Twig

apologies if this has been asked, I don’t seem to be able to find the solution. What is the correct way to call craft.app.session.set in a Twig template (or any other setter function for that matter)? ...
1
vote
1answer
32 views

Freeforms Check Submission is true

I'm trying to create a form that adds a cookie so that someone who has submitted the form can see content on the thank you page to protect the download. Currently I've got this: {{ craft.freeform.form(...
1
vote
2answers
33 views

How can I ensure certain items always display at the end of a list?

I have a website where I want to show Power Coat (-PC) options at the end of a list. The data goes into Craft in an unpredictable order, from a third-party service, so I am responsible for organizing ...
1
vote
2answers
38 views

Sort Entries by Value from Dropdown

I have a list of students and can sort them by name, sport, and school. The name and sport portions are easy, I'm grabbing the values without issue. Where I'm struggling is the school value is from a ...
1
vote
1answer
30 views

Where does Craft store HTML Templates?

I have recently been given access to a Craft site's control panel. I need to edit the homepage to add data in the footer. As I didn't create the Craft website, how can I access the HTML I need to add ...
1
vote
1answer
20 views

Asset file permissions issue hyperlane

I am having trouble setting up image volumes correctly in Hyperlane. My best guess is that is has something to do with permissions but I have not been able to find a solution. This is how I have set ...

1
2 3 4 5
32