Questions tagged [templating]

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

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

“Template not found” in live-preview

I am using docker for my local webdev and am new to Craft CMS. Currently I have a simple setup running, however, my Live-Preview does not seem to work and throws the "Template not found" error. Yet, ...
0
votes
0answers
7 views

Which twig file is being used and how?

I have a page in Craft (2.x) that displays several links and I was able to find which twig file had those links by searching the code base of twigs. Those links point to some Angular code with links ...
0
votes
1answer
18 views

How to insert widgets in Rich Text field

I want to insert widgets in arbitrary positions in one of my rich text fields. A good example would be a contact form inserted in the middle of the content. These widgets would be ad units, forms and ...
1
vote
1answer
14 views

User profile page

I'm looking to setup a profile page, displaying a users details (address etc) and they're current membership status (which will be down the Stripe Payments plugin.) I'm having some trouble getting ...
1
vote
1answer
44 views

My month/year archive template code no longer works in 3.2

My blog has a date archive page that uses a variation of this code. Here's the code that I've been using: {% set allEntries = craft.entries.section('entries').type(['posts','reviews']).limit(null)....
3
votes
2answers
81 views

How to access HTML input values from Twig and vice versa

I am new to Craft and Twig in general. I have encountered the following problems and struggling to find a solution for hours. I want to access the value of "foo" input field inside the twig ...
0
votes
0answers
22 views

Checking if entry field exists - dot vs bracket notation

Let's say I want to check if the field exists in entry. When I try to check for some no-nexisting field using dot notation it incorrectly returns true - entry.somefield is defined If I use bracket ...
1
vote
1answer
24 views

Get an Asset's Filename Without the Extension

How do I get an asset's filename without the extension? So if my filename is my_cool_photo.jpg I want to return my_cool_photo. Using {{ entry.assetsField.one.filename }} returns the name of the file ...
0
votes
0answers
20 views

Customizing display order of category entries to match admin (order as Structure)

I'm working on a Craft-based site that has a category defined for "Members". I can see in the admin panel one has the ability to drag the entries for this category in any arbitrary order (when ...
1
vote
1answer
26 views

Category query returning one fewer items than requested

I'm building a knowledgebase for a client. The client has asked for content to be restricted by category and then by user. This part is easy enough - the users now use the same category field as ...
1
vote
1answer
34 views

Navigation is throwing Twig error when trying to 'preview' a disabled entry

I have an entry that needs to be disabled until the content is finalized. I am not able to 'preview' the entry unless I enable it. If I remove the navigation code, 'preview' will work on the disabled ...
1
vote
1answer
24 views

Explanation of Deprecation Warnings

Why is this depreciated? Is there an example of the preferred method? Looping through element queries directly has been deprecated. Use the all() function to fetch the query results before looping ...
0
votes
0answers
20 views

Double encoded querystring parameters in pagination urls

Since upgrading to Craft 3.2 I've noticed that my querystring parameters are double encoded in my pagination urls? Example below: /search/p2?s=cancer&t%255B%255D=blog Edited: After a bit of ...
1
vote
1answer
31 views

Render template from Module in twig template

I have been searching around SE and the web in general for an answer to this. There seems to be plenty of solutions but none appear to be working for me. I have a simple module that has a variable ...
0
votes
0answers
17 views

Twig Include is displaying empty modules on page

I have a twig file called "Abilities.twig" inside abilities I have the below code: <p>{{ module.Ability }}</p> In the CMS I have a field set named "modals" with the field block "...
0
votes
0answers
7 views

Feed Me Plugin - can't authenticate when using inside templates

This is in reference to Feed Me's ability to call a feed directly from within a template. My issue that the feed I am hitting requires an authentication header to be sent at the same time in order to ...
1
vote
1answer
32 views

Undefined index error in trying to duplicate file

I've inherited a Craft-based website, and I'm much more familiar with WordPress, so please pardon the extremely basic question: the homepage for this site uses {% extends "_layout" %} and then ...
0
votes
0answers
17 views

Implementing Mollie Payment Gateway

I'm having a bit of trouble with the Mollie Payment Gateway and how it works, the docs are a bit...short. I know that Mollie is an off-site payment gateway, with that I have a few questions: I've ...
1
vote
1answer
42 views

{{siteUrl}} not working on load

I am using {{ siteUrl }} for absolute links. It works 95% of the time. But if I press the reload button multiple times in a few seconds (overloading or something) my links look like this: href="$...
1
vote
1answer
19 views

Merge a structure and a single section

That is written so inefficently: {% set indexNavi = craft.entries.section('pageContent').level(1).all() %} {% set bookingLink = craft.entries.section('booking').all() %} <ul class="navList"> ...
0
votes
0answers
12 views

How would override a single CP template?

I would like to override the "_special/image_editor.html" template, to allow more constraint possibilities. How would override this template ? Nicolas
2
votes
1answer
30 views

Check for number less than x in array

I want to check if there is a number less than 10 in an array. {% if 10 in [0, 30, 50, 10, 9, 200] %} {# checks only if there is a 10 in it. not if there is anything below 10. #} yep. there is ...
1
vote
1answer
13 views

Sort Categories by Entry Updated

I have the following Category loop code which I'm trying to sort by the date the entries within have been updated. e.g if an entry was just updated within a category, this category would be at ...
1
vote
1answer
26 views

Use function provided by plugin only if plugin is installed and enabled

I want to use asset rev in my template, but only if plugin is installed and enabled: {% if craft.app.plugins.getPlugin('assetrev') is not null and craft.app.plugins.getPlugin('assetrev')....
0
votes
0answers
25 views

Removing Plugin from Project.yaml

I'm trying to remove a rogue plugin from my Project.yaml - it's refusing to go! It's not in composer.json It's not in composer.lock It's not in my plugins DB table. It's not in my plugins CP list. ...
1
vote
1answer
22 views

Restricting access to user groups with Control Panel access only

I know I can restrict template output to Admins only with : {% if currentUser.admin ?? false %} …and to any logged in user with: {% if currentUser ?? false %} And I’m aware of accessCp as a ...
1
vote
1answer
57 views

Filter entries with AJAX

How would I sort blog entries displayed using AJAX? What I want to achieve is initially show all posts from a channel (All) but then let my users sort through these posts with a sub navigation using ...
1
vote
1answer
195 views

How to do CSS/JS bundles/minifying in Craft 3

I would like to combine all of my sites JS-files into one bundle - and perhaps also obfuscate it. Same goes for CSS-files. How would I do that in Craft CMS 3?
1
vote
1answer
31 views

Neater way to merge this conditional entry query?

I know there's a better way to do this - eg by merging in the relatedTo parameter if categorySlug is defined rather than defining 2 different queries, but I can't for the life of me figure it out... ...
0
votes
0answers
12 views

Tag list not displaying All Tags

I have this loop, but it's not actually displaying all tags? Is there a reason for this? {% set relatedTags = user.userInterests.all() %} {% if relatedTags|length %} {% for rel in ...
1
vote
3answers
66 views

Paginate Tag Page

I'm looking to paginate my tag page, but unfortuntately it throws a fairly strange error. Remove the pagination -> the page works perfectly? Bit confused, the only thing I think it may be is that it's ...
1
vote
2answers
30 views

Access entry content in _layout.html

I have some content I wish to output in the main parent _layout.html template. Seems like something simple to achieve but can't seem to figure it out. If I call {{ entry.bannerLabel }} etc it throws ...
2
votes
1answer
40 views

How to re-populate form with old values when submitted from a controller?

I have a form in a template which makes a request to the specified action (a controller). The controller decides that there is an issue with the inputs and needs to provide error output for the user. ...
1
vote
1answer
24 views

Craft 2: get default user group from user settings

In Craft 2, I know I can get general config settings. How can I get the current Default User Group (set in Settings > User Settings) for use in my templates?
2
votes
1answer
52 views

Order by Numeric Custom Field Value

I'm trying to order my entries by a numeric custom field named score, some of these values can be 0 but unfortunately, it's not getting ordered at all? {% set users = craft.users.group('influencer')....
1
vote
1answer
15 views

Related Entries to Users

I'm currently doing the following query, it's working nicely on my local environment but on Production it's allowing all users to see all entries which is really strange? I can't see anything wrong ...
1
vote
2answers
15 views

Why is category.getUrl() returning incorrect subdomain?

Forgive me if this is a server configuration or other issue unrelated to craft, but perhaps someone has some insight on what might be causing this, and how to fix it. When using a simple category....
1
vote
1answer
24 views

Replace throwing Unknown Modifier Error

I've tested the regex and seems to work perfectly, but when placing it within Craft it seems to throw the following error: preg_replace(): Unknown modifier '/' {% set ig = user.instagram|raw|...
1
vote
1answer
12 views

Entry Group Empty State

I have entries that are getting grouped, but I've noticed that it will return nothing if there's nothing within a group. I'm looking to see if there's a possibility of showing an empty state to a user?...
1
vote
1answer
12 views

Merging params PostDate limits errors

I'm attempting to merge in postDate restrictions based on the url segment. However I get twig errors with my code. So for a link of domain.com/news/archive/2016 I want to see all entries with a ...
1
vote
1answer
28 views

Offset not working correctly

I have an entry that has a entries field where 9 entries have been added. The first three entries are displayed in one block at the top of the page and this works correctly using .limit(3) However ...
1
vote
1answer
11 views

Show Users who have a related entry

I'm looking to show the users that have an entry relating to the currentUser, it is currently working but is obviously showing duplicates e.g. admin, admin as admin has 2x posts associated. Is there a ...
1
vote
1answer
34 views

AJAX Update Entry (500 Internal Server Error)

I'm trying to update an entry on the front end with a click and without a form. I'm a bit new with AJAX but would love to simply put a new title for the entry that the button relates to. I'm currently ...
1
vote
2answers
40 views

Creating entries loop with nth loops across unordered lists

I'm looking for some help with the most efficient and performant way to generate this loop. | COL 1 | COL 2 | COL 3 | | 1 | 2 | 3 | | 4 | 5 | 6 | | 7 | 8 | 9 | | ...
1
vote
1answer
23 views

Get and display a product's variant fields in twig

I'm working on a product template that can display products of any type. Various product types have varying numbers of variant fields each with their own options as other products. (All of my variant ...
0
votes
0answers
15 views

Injecting filename into all templates?

I found a topic about getting the current filename for templates here: How can I make a template output its own filename? but I am curious, is there some way I can get the server to implement this ...
0
votes
0answers
32 views

Craft Commerce Stripe Not Creating Subscriptions

I have the following code trying to sign up someone to a subscription plan using Stripe Commerce. Unfortunately, no subscriptions are getting created in Stripe Test and no errors are getting given. {%...
0
votes
0answers
18 views

Restricting Access Per User Posts

I'm looking to restrict access to users posts until another user follows for a development site I'm building out, but I can't get my head around how to sort the permissions. Here's the current ...
1
vote
1answer
21 views

Values from fields in templates

I have categories in my cms. How do I gets a list of these value into my templates? Thanks.
2
votes
1answer
13 views

Iterate through all rows of specific page using Freeform?

Documentation (http://docs.solspace.com/craft/freeform/v2/template-objects/page.html#usage-in-templates) says you can iterate through all rows on CURRENT page or entire form. I need all rows/fields ...