Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [templating]

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

0
votes
0answers
5 views

Asset Upload Form Field Error States

I currently have an asset upload field, but I'm trying to make it call errors back if the image isn't an extension that's set within the field, allowing users to understand why the form didn't save. ...
2
votes
1answer
7 views

Including a variant segment in product type template route in Commerce 2

Is it possible to use a wildcard when specifying the template path for a Commerce 2 product type? I want to format my URLs as /type/product/variant Where 'variant' could be a custom field applied to ...
0
votes
0answers
20 views

Using Label instead of Value from Dropdown

I currently have this dropdown on a front-end form, the problem I'm having is that it's saving the value where I really want to use the label in my templates such as United Kingdom instead of ...
2
votes
2answers
19 views

How can I add Google MarkerClusterer library to Smart Map?

I started to work with Craft CMS a couple month ago, I have a client that wants to have a clustered map, I went over Smart Map documentation but I couldn't find anything about on how to add Google ...
0
votes
1answer
31 views

Displaying related image assets from another section with twig

I have a site that shows upcoming football matches in a table, and I would like to include the clubs' logos next to each club name. I have the following sections and entry types, both generated using ...
1
vote
1answer
16 views

Front End Entry Form Select Dropdown Error

My front-end new entry form works, but when I add the complexity of a dropdown to the mix - it error's and doesn't save the entry. (I found this out with trial and error, removing fields until I found ...
1
vote
1answer
14 views

How do I setup the Login Page to work with requireLogin?

I want to create a login page. It would be a Single. The URI is set to login. So how do I name and map the twig file? I tried: creating a login folder under templates. naming the twig file ...
1
vote
1answer
21 views

Rendering HTML Heading Elements in Twig

I am rendering some headings using twig and want to know if there is a better and more readable way of doing the following... <{{ block.headingType }} class="measure-wide">{{ block.headingText }...
1
vote
1answer
20 views

Structure listing order & classes based on lightswitch value

I have a structure called "Projects", which I am currently listing on a page. The layout looks like the below - with the every row starting or finishing with a .wide class thumbnail: This is the code ...
1
vote
1answer
14 views

Access Default User Photo

I'm calling user photo's from my template, but it error's out when trying to obviously call a user photo which is empty. What I'm trying to achieve is if there is no user photo, use the default ...
1
vote
1answer
25 views

Updating User Photo from Front-End

I have this form, there's no errors getting thrown and the User photo field is not updating via this form. <form method="post" accept-charset="UTF-8" enctype="multipart/form-data"> ...
1
vote
0answers
16 views

Escaping rich text fields to json but keep html markup

I am trying to create an export from an old Craft2 site over to a new Craft3 site. The structure and fields are all different, so I figured the easiest way was to create a json file from my entries ...
1
vote
2answers
25 views

Delete Entry from Front End

I have this form <form method="post" enctype="multipart/form-data"> {{ csrfInput() }} <input type="hidden" name="action" value="entries/save-entry"> <input ...
1
vote
1answer
25 views

Variable “entrySlug” does not exist Routing

I currently have a routing set up as follows to enable an "Edit" entry page following on from this question but I'm getting the following error message when going to that page. Variable "entrySlug" ...
1
vote
2answers
40 views

Edit Entry Page

I currently have a freeform which allows logged in users to create an entry from the front end. I'm looking to build an edit page for each of these entry's so the user can come back and edit it if ...
1
vote
0answers
24 views

What the best strategy to test Craft template?

I would like to know if there is a way unit test templates using Craft 2.5? For example trying to prevent null pointers happening in production when an image is remove from the entry
1
vote
1answer
21 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
37 views

How do I fix a deprecation error for DateTime::year?

I am trying to work through deprecation warning. I have not touched Craft in a few months, so I am a bit rusty. The Deprecation Message is: DateTime::year is deprecated. Use the |date('Y') filter ...
0
votes
0answers
23 views

Users public profile pages without routing

I am creating a membership/community based website and i want to users have public profile pages. I read other answer but i do not want to use Routing in this. Routing creates lots of SEO errors (bots ...
1
vote
1answer
32 views

Craft CMS 3 Boilerpoint Web Project Setups Available?

Does anyone have any recommended boilerpoints or guides on setting up Craft CMS 3 with front-end tooling? Looking for an initial install to be setup properly with a preconfigured database, NPM, node....
1
vote
0answers
27 views

Calling unknown method: craft\web\twig\variables\CraftVariable::embeddedAssets()

I get this message while trying to access embedded Asset with the plugin Embedded Assets 1.0.2: Calling unknown method: craft\web\twig\variables\CraftVariable::embeddedAssets() I was fiddling around ...
0
votes
1answer
25 views

How do I assign a language to all datetime outputs

I am building a german calendar and am struggling having one language throughout all datetime outputs. The website is set to lang = de but the outputs of the solspace calendar is still english.
1
vote
2answers
49 views

Contact Form Setup on Craft CMS

I am just getting to grips with Craft CMS and am finding the Contact Form plugin tricky to use. I have built a reasonable site structure, figured how fields, sections, etc work at a relatively basic ...
0
votes
0answers
21 views

Only allowing users to change their own profiles

I have added public profiles following an answer on this stack exchange and it works great, the problem arises when adding a "User Profile Form" which allows users to update their own settings. The ...
2
votes
1answer
25 views

How can I use slim templates with Craft?

Coming from ruby and rails, I’ve been using slim (https://slim-lang.org) for years. It’s brevity and clarity have become the norm to me and writing and reading full html feels a bit exhausting. I ...
1
vote
1answer
20 views

Failed Stale Template Cache Delete Error…Analyzed…But No Answer

For some of the extremely static content on my site, I use caching to prevent multiple db queries during every single load. I also have multiple locale on my site with custom cache key names. The ...
2
votes
1answer
15 views

How to directly get value of text field in a given section of type structure?

I am trying to get a value of a text field that is in a Section which is a structure and has multiple entry types. I don't want to use a loop. I tried this and some other variations but does not give ...
1
vote
1answer
79 views

Templates, Routes, and URL segments

In EE, if there was a template /foo/bar.html, one could access the contents of that template by going to either example.com/foo/bar or example.com/foo/bar/more/segments/here. The additional URL ...
1
vote
1answer
23 views

How can I use asset select modal in utility?

I created a custom utility template. Inside the template, I would like to use the built-in asset select modal for the "Add image" button. Any way to do this please?
1
vote
0answers
14 views

How to handle URLs of entries with no category?

I have a section where most entries have a category assigned to them, but a few ones have no category at all. I need help how to connect these entries' URLs to my entry template. So far I used a ...
1
vote
1answer
12 views

Craft 3 setPasswordPath config not working for front end users

How do I change the link that's sent in a forgot password email that's sent to front end users in Craft 3? The setPasswordPath config isn't working for me. The users don't have access to the CP. In ...
1
vote
1answer
25 views

Eager Loading Relatedto & Target Elements

I have quite a substantial amount of queries heading out for this bit of code below. I've tried quite a few things to get it down, but I need to eager load some things just to try and reduce the ...
1
vote
1answer
15 views

Is there a query parameter to get categories that are related to anything else?

I'm looking for a way to query all categories that have at least one relation. I'm not looking for the relatedTo() parameter, which would give me categories related to something specific. Basically, ...
1
vote
1answer
21 views

hashing form fields to prevent tampering

I have a front end form for entry creation. I have a few options I don't want tampered with. The docs for |hash say "Prefixes the given string with a keyed-hash message authentication code (HMAC), for ...
1
vote
0answers
18 views

Entries sorted by title have some entries not alphabetical

I have the following code to return some grants, but whilst most of the entries are coming back alphabetically ordered, after the last "Z" entry, there are a few more entries also alphabetically ...
1
vote
1answer
50 views

where command sql query not working

My problem is that I can't update the specific $userId. have the values I've selected. I also get an error: Call to a member function where() on integer I just started to learn Craft. It can be ...
1
vote
2answers
27 views

Nested category navigation

I am trying to achieve the following markup for my categories navigation: <h3><a href="categoryurl">Top Category One</a></h3> <ul> <li><a href="categoryurl"&...
1
vote
1answer
21 views

Mobile page support

Is there any good practice to how to serve mobile pages differently from Twig? What I would like to achieve is the following, right now we have pages like: http://myawsomecraftpage.com/stories/aaa-...
1
vote
1answer
27 views

Connection between twig template and website content

I am new to Craft and I am basically inheriting a site that I now need to maintain. I am a developer, not really a web designer, and my current task is to change the layout on the homepage. ...
1
vote
2answers
28 views

Sending Error Message to Template With No Logged In User - Craft 2

I'm working at getting error messages sent from my plugin to my template (on the front end), when there is no session (no logged in user). The plugin is for LDAP authentication. Edit: For ...
2
votes
1answer
31 views

RelatedTo “and” and arrays

I have something I can not get my head around. This works as expected: .relatedTo(['and',{targetElement:22},{targetElement:33}]) But when I am building an array to use as relation criteria like so: ...
1
vote
1answer
26 views

Get to get all users with active Commerce 2 subscription

How do I get all the users with an active subscription in Commerce 2? I want to be able to filter entries by subscribed users.
1
vote
1answer
66 views

Eager loading on entry not reducing queries

Using this snippet returns me 38 queries on my homepage without the Eager Beaver plugin. {% do craft.app.elements.eagerLoadElements( className(entry), [entry], ['headerImage', 'image1', '...
1
vote
1answer
31 views

CKEditor Null Value

I'm using CKEditor as one of my fields, I'm trying to detect if there is any content within them, unfortunately it's still appearing even using the below code (and the field is actually empty). {% if ...
1
vote
1answer
37 views

How can I list Entry Types of a single Section?

The following outputs all sections and their entry types, but I'm struggling to work out how I output only the entry types from the "blog" section. {% for section in craft.app.sections.allSections() %...
1
vote
2answers
23 views

Counting section handle in TWIG with weighted search plugin

I am using the weighted search plugin to inplement a search functionality in my site. It works as it should but I am looking for a way to tell how much results were found of each type. Where type for ...
0
votes
1answer
14 views

field from category not available via craft.categories

my categories have a custom field called titleTag for SEO as well as a number of other fields. When I render them at their URI (/categories/cat1) I can output those fields easily with {{category....
1
vote
1answer
40 views

How to wrap a matrix blocktype occurrence loop inside a ul?

I made a template including a matrix field. I want to wrap all occurrences of a certain block type into a <ul> element. How can I do this? My current code: {% for block in entry.matrixField....
1
vote
3answers
24 views

Keeping order of blocks like in backend

Fairly new user here. I am kinda confused how to template. I want to rearrange the order of blocks in my backend and show them in the right order in the front. Here is how i am currently writing a ...
1
vote
1answer
62 views

How to use the default HTML email template when sending an email from a plugin?

On /admin/settings/email, when the HTML Email Template field is set to a valid template, all system messages are sent using it. They inject the content of the messages inside the {% block main %}{{...