Drupal StackExchange

Unable to edit node translation other than current language

5 days 18 hours ago

On my multilingual site I seem to have problem at admin/content when editing a particular translation.

I have a Contact Us page, translated:

Contact Us [EN], node/286 Contact Us [ES], node/300

I don't have an explicit Path Translation set, but the nodes are bound together, in the Translate tab.

Now the problem is, that when my current language is English and I want to edit the Spanish version from the Content listing, the edit link takes me to its English version (node/286). Apparently the admin overlay inherits the language prefix and forces the English translations to open.

What luckily works correctly is editing the node from within its view (by hitting the Edit tab).

Is this normal behavior?

no more drupal

Using Twig in global custom text to check for a specific content type

5 days 19 hours ago

I am filtering for two content types to display in a view: Artwork Page and Cover Page. I want to change the HTML markup for Cover Page.

I have researched and tried many field names for Content Type, but with none of them I get what I am trying to achieve. In this instance, the replacement pattern for Content Type is {{ type }}; using it doesn't work. I've tried both the machine name (cover_page) and the name (Cover Page), but neither of them worked.

{% if type == 'cover_page' %} <h1>THIS IS THE BEGINNING</h1> {% endif %} {% if type == 'Cover Page' %} <h1>THIS IS THE BEGINNING</h1> {% endif %}
David Crellen

How can I add a class to a label?

5 days 20 hours ago

I need to add a class name to certain labels created by Drupal's form API like this:

$form['name'] => array( '#type' => 'textfield', '#title' => 'Prénom' );

If I use the following, the <textarea> gets a class, but not the label.

$form['name']['#attributes']['class'] = array('myClass');

I'm looking for something similar that will add a class to the <label>.

Shawn

Get web image url from real path

5 days 20 hours ago

As part of some other functionality I am generating an image in temp folder and But unforunately I'm not able get the web url of image.

$path = \Drupal::service('file_system')->realpath(file_default_scheme() . "://"); $image_path = $path . rand() . '.png'; echo $image_path;

I am getting following as path

C:\wamp\www\www_d8test1_com\sites\default\files30605.png

How can I add slash before image name and get actual weburl of image like below?

http://www.d8test1.com/sites/default/files/30605.png
Cool

How do I use Taxonomy reference field tokens in a path alias?

5 days 21 hours ago

I have a content type with two taxonomy entity reference fields. Both are required fields that only allow one value. I have path_auto and token enabled. I would like to use them to set the path of the node type.

This is the path pattern that is a problem:

[node:field_main_site_section:entity:name]/[node:field_content_category:entity:name]/[node:title]

It looks close to the answer given in another questionn here.

Result: The only thing showing up in the path is the title.

Versions: Drupal 8.8.5, pathauto 1.8, token 1.7

What have I tried?

I tried running the code through the debugger and found out that the action is in the functions PathautoGenerator::createEntityAlias() and Token::generate(). I see that the three tokens are found and that a Node data is passed to Token generate. Then the generate function runs $replacements = $this->moduleHandler->invokeAll('tokens', [$type, $tokens, $data, $options, $bubbleable_metadata]). There were 9 modules found that implement hook_tokens but the only one returning any data is node_tokens. Looking at that code I don't see any attempt to return fields.

I also found an issue on the token module that indicated that I might be missing Token view modes. I was indeed missing a token view mode for my two taxonomy vocabularies so I created them. I added each field in the vocabulary including "name" in plain text.

I also tried to guess that the node needed to be converted to an entity to grab it's fields:

[node:entity:field_main_site_section:entity:name]/[node:entity:field_content_category:entity:name]/[node:title]

That was an invalid pattern.

Question: What is the correct pattern or what else do I need to configure?

lolcode

Calendar From Multiple Content Types

5 days 22 hours ago

I have a 4 seperate calendars created on drupal; each with their own content type. Each of these need to be able to be viewed on their own but I'd also like to be able to combine all of these calendars into one master view and can't seem to figure it out.

ie. Meetings calendar, Holidays calendar, Staff Events calendar.

Any help would be greatly appreciated. I'm new to Drupal so please be gentle.

Thanks

user697508

Nivo Slider jQuery plugin Not installed

5 days 23 hours ago

I´m trying to install Nivo Slider to my website. I was following this tutorial from the official plugin website.

I have the folder "all" an inside it I have "libraries", "modules", and "themes". I extracted the FlexSlider-master.zip in my libraries folder, and rename it to "nivo-slider".

The second step was install the extension from the url drupal/project/nivo_slide without drush, download the folder an upload to my server in modules/.

I have clear the cache but the problem persist.

Can someone help me? I can´t upload pictures or links with less than 10 reputation.

Leonardo Cavani

main menu link as language switcher

6 days ago

I have 2 language and these situation:

  • main menu -> lang1 -> link to www.foo.com/
  • main menu -> lang2 -> link to www.foo.com/en

All sites when switch manually on browser the language, But my main menu link not work.

I have no space to place an other block with menu switcher on main menu bar.

I hope someone can send me in right direction because I spent 8 hour around these without solutions?

theman whosoldtheworld