Drupal StackExchange

Action links available options / caching

2 days 14 hours ago

I have some action links defined in module.links.actions.yml which uses a custom "create entity" route. For entity creation I set up some restrictions and at some point the access is denied. The problem is that whilst the access to the page is denied, the action link is still visible until I clear all caches.

Is there a way to tell Drupal not to cache the links or to programmatically clear the links cache? Or some options I can add in the yml file to prevent caching?

Thanks.

Marius Ilie

Styling a "programmatically created block" in drupal 10

2 days 14 hours ago

I'm new to Drupal dev, I'm messing around creating some custom modules and explore how the env of drupal 10 works... I've created a custom block that i called "Copyright":

<?php declare(strict_types=1); namespace Drupal\plugin_play_module\Plugin\Block; use Drupal\Core\Block\Attribute\Block; use Drupal\Core\Block\BlockBase; use Drupal\Core\StringTranslation\TranslatableMarkup; #[Block( id: 'copyright_block', // id is the internal machine name, admin_label: new TranslatableMarkup('Copyright'), category: new TranslatableMarkup('Custom') ) ] class Copyright extends BlockBase { #[\Override] public function build(): array { $date = new \DateTimeImmutable(); return [ '#markup' => \t('Copyright @year&copy; My Company', ['@year' => $date->format('Y')]), ]; } }

and after I placed it in footer region using UI, I wanted to style it a little... Based on some inspection:

I have added some css:

.block__content{ text-align: center; color: green; }

but at the end, nothing changed here's the config for that custom module :

#plugin_play_module.info.yml name: Plugin Play Module description: playing with plugins type: module core_version_requirement: '>=9' libraries: - plugin_play_module/copyright_block #plugin_play_module.libraries.yml copyright_block: css: layout: css/styles.css: {}

here the tree structure of the web/modules/plugin_play_module

│   ├── plugin_play_module │   │   ├── **css** │   │   │   └── styles.css │   │   ├── **js** │   │   ├── plugin_play_module.info.yml │   │   ├── plugin_play_module.libraries.yml │   │   ├── plugin_play_module.module │   │   ├── plugin_play_module.services.yml │   │   ├── **src** │   │   │   └── **Plugin** │   │   │   ├── **Block** │   │   │   │   └── Copyright.php │   │   │   ├── ...
tsukingo

Form and gated content

2 days 17 hours ago

UPDATED from earlier:

I am using a simple Drupal form that collect user info before allowing the user access to donwloadable content. NOTE: This is using the form API and I am no longer using a modal; just using a regular page created by a hook. Here is the scenario:

<?php function my_form_menu() { $items = array(); $items['form/userinfo'] = array( //this creates a URL that will call this form 'title' => 'Download Form', //page title 'description' => 'A form that gathers user infomation', 'page callback' => 'drupal_get_form', //this is the function that will be called w hen the page is accessed. for a form, use drupal_get_form 'page arguments' => array('my_form'), //name of the form 'access callback' => TRUE ); return $items; } function my_form() { if (!empty($_COOKIE['Drupal_visitor_downloadbypass'])) { drupal_goto('this is where the pdf file will go'); // rest of the page will not execute because drupal_goto ends the request. } $form['name']['first'] = array( '#type' => 'textfield', '#title' => t('First name'), '#required' => TRUE, ); $form['name']['last'] = array( '#type' => 'textfield', '#title' => t('Last name'), '#required' => TRUE, ); $form['name']['title'] = array( '#type' => 'textfield', '#title' => t('title'), '#required' => TRUE, ); $form['submit'] = array( '#type' => 'submit', '#value' => 'Submit', ); return $form; } function my_form_submit($form, &$form_state) { // $form_state['values']['example'] contains the submitted value of 'example' element. user_cookie_save(array('downloadbypass' => 1)); $form_state['redirect'] = 'this is where the pdf file will go'; }

So here is my question: Now my form page is not showing up and I didnt change the hook except for the form name argument. The form will need to redirect back to the previous page and open the file in a new window upon submission.

Thanks!

phi

DataGuy

localhost subsites configuration

2 days 18 hours ago

I know how to install a single instance of Drupal very well but I want to create a number of sub-sites under my Drupal installation. My file structure is as follows:

drupal7_main -sites --drupal7_sub1 settings.php --drupal7_sub2 settings.php

I'm developing on my localhost and the plan is to duplicate the structure on the production server.

However, only drupal7_main works. When I visit localhost/drupal7_main, Drupal is ready and configurable as usual; when I visit localhost/drupal7_sub1, I get the following error.

Not Found
The requested URL /drupal7_sub1 was not found on this server.

I get the same for drupal7_sub2.

I'm trying to learn this process and would appreciate some help.

sisko

Ignore parts of the url or dynamically rewrite/alias the url

2 days 19 hours ago

I am having a problem and have been wrecking my brain over it...

I feel I might ohh how did I not think of that moment once I find the solution...

Basically, what I need to do is:

For any url containing a string like "abcmytrack" show the page/view/drupal url that is before it in url and ignore the rest. So if I go to node/1/abcmytrack/some/other/stuff/abc then just show node/1, if I go to nodeone/alias/page/abcmytrack/some/other then again just show nodeone/alias, but keep abcmytrack/some/other in the url.

What am I trying to do: there is some referral tracking that I am trying to implement in the form of.

/some/drupal/url/[trackid]/some/other/track/ids/even /any/drupal/url/[trackid]/any/even/number/of/arguments /[trackid]/some/other/set/of/arguments

basically for any url with [trackid] which is a string. It should just ignore anything starting with [trackid] and load the path before it as if [trackid] was not there.

The result is that they basically get converted to a cookie, but the site is behind varnish and akamai caching so on production the code does not run and cookie is not written. Best option at the moment is to use JS to write a cookie, but problem is that adding /[trackid]/some/other/set/of/arguments to some of the site urls like aliased node paths, homepage, etc. breaks the pages.

It might be possible to do it as url rewrites in .htaccess but this is a last resort. I would like to see if there are other options I am not considering.

I have attempted to do use hook_url_inbound_alter but it seems to do redirects and I loose the string from the url or otherwise it url encodes the string.

I have been wrecking my brain on this and cannot make this work. Granted I have some interesting requirements but it is one of those things that should be straightforward but it is not.

Boris Smirnov

Drupal Planet

Drupal Association blog: Making the Most of Your Time at DrupalCon Portland

2 days 15 hours ago

It’s less than two weeks to DrupalCon Portland 2024, and the excitement is building! If you’re gearing up for the biggest Drupal event of the year, we’re here to help you maximize your travel experience to Portland. Let’s dive right in!

Hotel Bookings at Great Prices

You still have a chance to book your DrupalCon Portland hotel within the official hotel block. By staying within the hotel block, you'll get the best proximity to the conference center as well as the chance to run into other Drupalists on your floor! Book now:

When and where is DrupalCon’24 happening in Portland?

DrupalCon North America 2024 will be held from 6th to 9th May 2024 at the Oregon Convention Center (yes, in-person!). Located right in the heart of the city, it is a perfect hub for exploration. You'll find hotels, restaurants, and shops just around the corner. It's also super easy to get to fun stuff like entertainment and hiking. With endless possibilities, you're sure to find something that suits your fancy.

Things you should NOT miss out on in Portland

May is a delightful time to be in Portland, with spring in full bloom. Enjoy the sunny weather and mild temperatures, making it the perfect season to explore the city's vibrant outdoor scene. There are several must-visit places that capture the city's unique charm.

1. Governor Tom McCall Waterfront Park

This is the perfect place to enjoy Portland's beauty while watching the river flow by. Visitors to the park can enjoy a variety of recreational activities, from leisurely strolls and picnics to jogging and biking along the paved pathways. The park also hosts numerous events throughout the year, including festivals, concerts, and outdoor markets, adding to its vibrant atmosphere.

One of the park's highlights is the Salmon Street Springs Fountain, where children and adults alike can cool off in the refreshing water jets during the warmer months. The park also features several monuments and public art installations, adding cultural and historical significance to its landscape.


Image Source: https://www.travelportland.com/attractions/governor-tom-mccall-waterfront-park/

2. Powell's City of Books

Powell's City of Books is a literary wonderland located in downtown Portland, Oregon. As the world's largest independent bookstore, Powell's spans an entire city block and boasts multiple floors filled with books of every genre imaginable. One of Powell's most unique features is its rare book room, home to a collection of rare and out-of-print titles, first editions, and signed copies that will delight bibliophiles and collectors alike.

In addition to its vast selection of books, Powell's hosts author readings, book signings, and other literary events, fostering a sense of community among book lovers from near and far.


Image Source: https://www.travelportland.com/attractions/powells/

3. Portland Art Museum

Founded in 1892, the Portland Art Museum is the oldest art museum on the West Coast and holds a rich and diverse collection of artworks spanning various time periods, cultures, and mediums. It is located in the heart of downtown Portland. One of the museum's highlights is its extensive collection of Native American art, which celebrates the rich artistic traditions of indigenous peoples from the Pacific Northwest and beyond. 

In addition to its permanent collection, the Portland Art Museum hosts rotating exhibitions that showcase both established and emerging artists, offering visitors the opportunity to engage with cutting-edge contemporary art and explore new perspectives.


Image Source: https://www.travelportland.com/attractions/portland-art-museum/

4. Voodoo Doughnut

Voodoo Doughnut is more than just a bakery; it's a Portland icon, a symbol of creativity, and a culinary experience like no other. It was founded in 2003 by friends Kenneth Pogson and Richard Shannon and has gained international fame for its wacky doughnut creations.

It is located in the heart of downtown Portland, Voodoo Doughnut draws long lines of locals and tourists, eager to sample its unique offerings. Some of the must-try snacks: Voodoo Doll doughnut, pretzel stake and raspberry filling, Bacon Maple Bar topped with crispy bacon strips. If this has got you drooling (like me), make sure you head to this place while you’re at Portland.


Image Source: https://www.travelportland.com/attractions/voodoo-doughnut/

5. Oregon Museum of Science and Industry 

The Oregon Museum of Science and Industry (OMSI) is a beloved institution in Portland, Oregon, dedicated to inspiring curiosity and fostering a love of science through engaging exhibits, interactive displays, and educational programs. Located on the east bank of the Willamette River, OMSI's sprawling campus encompasses a variety of attractions that cater to visitors of all ages. 

OMSI's planetarium is a highlight, where visitors can explore the wonders of the night sky, learn about astronomy and astrophysics, and take virtual journeys through space. The museum also features a state-of-the-art IMAX theater, where visitors can experience immersive films on topics ranging from nature and wildlife to history and technology.


Image Source: https://www.travelportland.com/attractions/omsi/

Find more information to plan your trip here.

Drupalize.Me: Learning Drupal with the Help of an AI Tutor

2 days 17 hours ago
Learning Drupal with the Help of an AI Tutor

TL; DR: Use this prompt and the text from a Drupalize.Me tutorial to experiment with using generative AI as a tutor for learning Drupal.

A while ago, I wrote an article and gave a presentation about why learning Drupal is so hard. One of the key challenges I identified is the “pit of despair”. It's that point in the learning journey where you can no longer rely on the hand holding of step-by-step tutorials. You need to step out into the chasm and come up with your own unique solutions to your specific problems. That point where you know just enough to realize the breadth of what you don’t yet know. And I had said, based on input from many peers, that the quickest way through the dip is real-world experience and drawing on the expertise of others. The advice could be summed up as: if you want to learn fast, get a tutor.

It can be hard to find a mentor. As much as we would love to be able to do so, our small team at Drupalize.Me can't scale personalized individual tutoring. So I've been thinking about how you might be able to use AI to help get at least some of the benefits of tutoring.

joe Thu, 04/25/2024 - 11:29

The Drop Times: DrupalCollab: How big is the Drupal Community?

2 days 19 hours ago
The Drop Times delves into the dynamics of the Drupal community with a detailed analysis of LinkedIn data, revealing the distribution and growth trends of Drupal professionals worldwide. This comprehensive study sheds light on regional concentrations and potential areas for community engagement.

Acquia Status

Acquia has detected a temporary interruption in Acquia Cloud interface services

2 days 17 hours ago

Apr 25, 15:52 UTC
Resolved - The underlying cause of this service interruption has been addressed. All services are currently operational. However, please note that the aggregated data for the affected time window has been lost and cannot be retrieved or backfilled.

Apr 25, 11:23 UTC
Monitoring - A fix for the cause of the interruption of service impacting some Acquia Cloud Stack Metrics has been deployed. We are currently monitoring the situation.

Apr 24, 19:07 UTC
Identified - The cause of the interruption of service impacting some Acquia Cloud Stack Metrics has been identified. We are currently working towards the fix and will provide additional information as it becomes available.

Apr 24, 13:28 UTC
Investigating - We are currently investigating an interruption in Acquia Cloud interface services impacting Acquia Cloud Stack Metrics to not report any Varnish data. We will provide additional information as it becomes available.