This forum is for assistance with theme development.

Can Twig "if" conditions refer to URLs? [solved]

I need to disable a script on the /user/login page.

I use the following condition to load a Simply Analytics script for anonymous users, but my own hits on the login page are, inevitably, being recorded and they are skewing the average page view times downwards.

{% if not logged_in %}
<script async src="https://scripts.simpleanalyticscdn.com/latest.js"></script>
{% endif %}

[solved] How do I change the content of a status message?

I would like to replace the impersonal default message which is shown to anyone who submits a comment, but my research has not found a working solution. 

The String Overrides module is the obvious go-to, but is not compatible. I found a suggestion to edit settings.php, so I tried the following code in my local test site…

Print a key (instead of the value) in a field template?

I've searched for this for a while now but found very little info about it. If you have a field which shows the selected value from a select input, and you want to use the key (ie. the machine name of each option value) as a unique class in the output, how can we do it? Is it possible, even?

What's the naming convention to target a specific block's template?

I'm trying to override the block template for a specific block generated from a view.

I'm using block--[module]--[delta].html.twig to name the template but can't seem to get the template to work after clearing cache.

It's the delta bit im struggling with - I can target all views blocks using block--views.html.twig perfectly fine, but I just want to target a certain block, not all views blocks.

Creating a "modal" from a link

In my comments form, I have a tick box field for visitors to agree to the comments policy. To that end, the field has help text which links to said policy.

As I would rather prefer to avoid causing any inconvenience, I thought that the best practice may be to show this node (or preferably only the body, but let's take one step at a time) in a small overlayed window, a la many other websites.

Adding a region to a bootstrap 5.x sub-theme

Bootstrap 5.x sub-theme by SymphonyThemes called Martex

Martex has a Top bar region that includes three regions for the logo, navigation menu and "navigation other"

I would like to add a region above Top bar. I would like to be able to put a three blocks in the new region that have social media links, etc.

I would appreciate a guide on how to "enable" one of the underlying bootstrap 5.x regions that would reside above Top bar.

I understand that this might mean I have to move existing regions down on the page.

Pages

Subscribe with RSS Subscribe to RSS - Theme development