Drupal StackExchange

How to add twig code in View 'global custom text' field?

1 month 3 weeks ago

I want to show a link when a node is published.

I added the Content: Publishing status field and hid it. In global custom text, I added the following code.

{% if status == 0 %} <div class="apply_job"><a href="/appy-job" target="_blank">Apply</a></div> {% endif %}

The replacement pattern for the published status is {{ status }}, which shows 0 or 1.

I am using Drupal 8.2.0.

Can anybody help me to make this work?

rks

No search results display when using core search

1 month 3 weeks ago

I have added Drupal the search module block and it displays the search form.

When I type and click on search button, it displays nothing, just a refresh in page only.

What do I need to do to get search results to show up? I could use alternative search modules if that is recommended/necessary.

Note: I've already indexed the content. In configuration page, it's showing "your 100% content has been indexed".

Manoj

How to show an Inline Entity Form on a PM page or panel?

1 month 3 weeks ago

I'm trying to include an Inline Entity Form on a panels display (via ctools Page Manager).

The Inline Entity Form field is attached to users, and the page in question has the user's context.

The Inline Entity Form field does appear in the panels interface, in two different ways, but neither work:

  • As a "User" field content type
    • It simply displays the text 1
  • As a "User (tokens)" content type
    • It simply displays the text 1
  • As a "Form" content type
    • It simply display the text Entity info
user56reinstatemonica8

Can't login: user/login redirects to index page

1 month 3 weeks ago

My Drupal 7 user, user login and admin pages all redirect to the index page. I am unable to login at all. This problem came up recently after the site had been unchanged for months. I can't think of a single reason this started happening all of a sudden.

Nothing looks funny when I debug in my browser. I have the following details based on my research:

  • No errors are appearing.
  • There were no updates, automatic or manual, to the site or modules.
  • I'm not using Secure Pages, Ubercart SSL, or any other SSL modules that might interfere. The site is pretty basic, simple Zurb Foundation theme, Views, and a couple other small modules, nothing fancy.
  • $base_url = 'http://sohp.us'; // NO trailing slash! Is specified in my settings.php file (located in root/public_html)
  • The Drupal instance was installed through cPanel's Softaculous
  • I downloaded the default .htaccess for Drupal 7 and replaced the existing one (no changes required).

It seems like the PHP for bringing up the login isn't working correctly, but I could definitely be missing something obvious or compeltely different from what I've been trying. If anyone has any suggestions on things to test out to get myself back in, it is much appreciated.

Thank you.

Joseph

List (distinct) users in order of their most recently published node

1 month 3 weeks ago

I'm trying to list 8 users (name and profile image) starting with the one who created the newest node and follow with the rest of users in (descending) order of their last created node.

I got to achieve it* by:

  1. adding fields and filters
  2. adding a Relationship (advanced) with Content authored
  3. adding Sort criteria as Content: date (descendant)

It 'works' but I get duplicated users. If a user created the 3 newest nodes, then it appears in positions #1, #2 and #3. I can't get it to get only distinct (unique) users in the list. Aggregation did not work.

SQL query (where I get users in the right order but with repeated ones) added:

SELECT DISTINCT "users_field_data"."created" AS "users_field_data_created", "users_field_data"."uid" AS "uid", "node_field_data_users_field_data"."nid" AS "node_field_data_users_field_data_nid", DATE_FORMAT((DATE_ADD('19700101', INTERVAL node_field_data_users_field_data.created SECOND) + INTERVAL 3600 SECOND), '%Y%m%d%H') AS "node_field_data_users_field_data_created_hour" FROM {users_field_data} "users_field_data" INNER JOIN {node_field_data} "node_field_data_users_field_data" ON users_field_data.uid = node_field_data_users_field_data.uid LEFT JOIN {user__roles} "user__roles_value_0" ON users_field_data.uid = user__roles_value_0.entity_id AND user__roles_value_0.roles_target_id = 'content_editor' WHERE ("users_field_data"."status" = '1') AND ("user__roles_value_0"."roles_target_id" = 'content_editor') ORDER BY "node_field_data_users_field_data_created_hour" DESC, "users_field_data_created" DESC LIMIT 10 OFFSET 0

Any clues? Ty

hip

How to open jquery dialog on menu click

1 month 3 weeks ago

I would like to open a jquery dialog that asks a question before taking the user to the desired page (ie do some page set-up before they get there). The catch here is that I would like to open the dialog when the user clicks the menu item. I am not sure how to go about this. Could someone point me to some examples where this is done or what I need to do? I am using Drupal 7.

Thanks.

user5013