widgets – Conditional tags based on previously viewed publications

I was looking at the conditional tag archive and wondering if it was possible to display a widget based on different messages / pages previously viewed by a visitor.

For example, if I had a car blog and the blog layout contains a sidebar widget that will display a promotion.

This promotion will vary depending on the types of messages visited by a visitor.

So, if a visitor was looking at publications related to the Mazda brand, I would be able to write a condition for the widget in the sidebar that reads, when he was visiting the blog post X, Y or Z, this widget will display a promotion for a Mazda car dealership near it.

Same for other types of cars and promotions.

I imagine that it would be impossible, but I thought that tracking a visitor with the help of cookies was a viable idea.

Do you have ideas or suggestions on where to go?

forms – How to set read-only fields (widgets) in hook_form_alter

Some of my nodes' fields are regularly updated by an external data source and should not be modified by Drupal's editors. But for UX reasons, I still need these fields visible on the editing form.

For input fields, I added the HTML code reading only attribute, which works pretty well:

function MYMODULE_form_node_form_alter (& $ form,  Drupal  Core  Form  FormStateInterface $ form_state, $ form_id) {
$ node = $ state_format-> getFormObject () -> getEntity ();

if ($ form_id == & # 39; node_MYBUNDLE_form & # 39;) || $ form_id == & # 39; node_MYBUNDLE_edit_form & # 39;) {
if ($ node-> hasField (& # 39; remote_id & # 39;) && $ node-> hasField (& # 39; remote_datasource & # 39;)) {
if ($ node-> get (<remote_id>) -> value && $ node-> hasField (& # 39; remote_datasource & # 39;) == & # 39; SET_BY_MY_IMPORTER & # 39;) {
$ readonlyFields = ['title', 'body', 'field_image', 'remote_id', 'field_minprice', 'field_roomsize', 'field_minoccupancy', 'field_stdoccupancy', 'field_maxoccupancy', 'field_roomamenity'];
foreach ($ readonlyFields as $ rof) {
$ form[$rof]['widget'][0]['value']['#attributes']['readonly']    = & # 39; read-only & # 39 ;;
$ form[$rof]['widget'][0]['value']['#description']    = t (& # 39; This is a read-only import field & dquo;)
}
}
}
}
}

But I have problems with these fields with the "advanced" (not HTML ) widgets:

  • body is a text field with CKeditor
  • field_image is an ER field with an entity browser widget for media entities
  • field_roomamenity is an ER field with a self-completion widget for taxonomy terms

Can any one give me a hint on how to set these widgets by read-only?

Sidenote:
I know that there is a read-only field widget module. But I do not want to change the type of widget because editors can create their own elements, which are not served by an external data source (where the fields remote_XXX). In these cases, publishers need these widgets in "write mode".

widgets – Implementing a sidebar with foldable boot cards

I'm trying to implement foldable boot maps (Bootstrap 4) on the widgets of the sidebar, until now I have this:

register_sidebar (
board (
& # 39; name & # 39; => esc_html __ ("New Sidebar", & nbsp;),
& # 39; id & # 39; => & # 39; new_sidebar & # 39;
& # 39; description & # 39; => esc_html __ ("New Sidebar", & nbsp;),
& # 39; before_widget & # 39; => & # 39;
& # 39 ;, & # 39; after_widget & # 39; => & # 39;

& # 39 ;, & # 39; before_title & # 39; => & # 39;
& # 39 ;, & # 39; after_title & # 39; => & # 39;
& # 39 ;, ) )

The problem is that each compressible container needs a unique identifier to find out which one is open or closed, but my problem is in "before_title". and & # 39; after_title & # 39; because I am not able to replace it with an identifier. Can someone help me? I'm still pretty new to WordPress.

Web Design – Progressive Disclosure Widgets for Very Long Pages

I face this challenge with my personal portfolio: how to make a long case study more user-friendly to compensate for the excessive content that causes a lot of horizontal scrolling.

Current prototype of the website: https://daniel-portfolio.netlify.com/case/blacktrax-website

I've tried this:

  • Reduce Text – Worked for some sections, but ended up cutting important details for the case, although my case has a size two times smaller than that of Simon Pan's Uber case study .
  • The reduction in white space is still going on, but I do not want to reach a point where I have to sacrifice the presentation. My goal is to create something between Simon Pan's detailed model and a marketing landing page.
  • Replacing images for videos (work in progress in some sections)
  • Progressive disclosure

In the case of a progressive disclosure, I would like to know your opinion on these widgets and their ease of use:

Bootstrap 4
http://getbootstrap.com/docs/3.3/css/#tables-contextual-classes
enter the description of the image here

Smartisan OS
https://www.smartisan.com/os/#/powerful
enter the description of the image here

Smartisan OS-6
https://www.smartisan.com/os/#/6-x

enter the description of the image here

Note: It appears that they are disabled for mobile on these sites.
Also, if there is any documented research on these types of widgets?