Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 873621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:58:06+00:00 2026-05-15T10:58:06+00:00

I currently having trouble to get my head around how Drupal’s views work with

  • 0

I currently having trouble to get my head around how Drupal’s views work with arguments when displaying a view as a block. I have a few simple pages (eg studios/bremen) and a few users that match those pages (eg username: bremen). Users can post news which need to be teasered on the studios/* page.

Do I have to use an Argument Handler that translates the node_id in arg(1) to the corresponding username, or is there an easier way?

I hope i could explain my problem so you can understand… this whole view argument thing feels kinda weird to me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T10:58:07+00:00Added an answer on May 15, 2026 at 10:58 am

    arg(1) won’t be a username or UID and not work the way you expect. What we can try though is to do a lookup and return to provide the default argument value in a roundabout way.

    ACTION TO TAKE IF ARGUMENT IS NOT PRESENT: set to Empty text, or, 404, whatever your preference.

    Provide PHP code for the Validator:

    if ($argument) {
       $user = db_fetch_object(db_query('SELECT name FROM {users} WHERE name = "%s"', $argument));
       if ($user) {
          $handler->argument = $user->name;
          return $user->name;
       }
    }
    

    The part you want to make sure about here is that arg(1) being a username on certain pages will not contain (or allow) characters to pass through causing a SQL injection.

    Username patterns can be controlled with Pathauto. This won’t stop someone from entering junk into the URL though, and Drupal/Views should be able to sidestep characters in the URL. You can test that by setting ACTION TO TAKE IF ARGUMENT DOES NOT VALIDATE to display a 404 page, or, empty text.

    Try this out and use the preview part of Views and see if it returns anything for you. I did this off the top of my head, but I do similar things all the time with different types of content or searches.

    You can also try setting the Validator to User, and Allow both numeric UIDs and string usernames. I haven’t used that setting, but it most likely will work as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey, I currently am having trouble trying to get this to work. Here's a
I am having some trouble wrapping my head around virtual proxies. I have read
The part of the application that I am currently having trouble getting to work
I'm having trouble getting my links the way I want them. Currently, I have
I am having trouble making this work and am looking for some help. Currently
Im having some trouble getting Ajax.ActionLink to work how I expect. In /views/layout/_Layout.cshtml I
I having a bit of trouble getting my head around Ioc and generics, and
I'm having trouble wrapping my head around Events and their Handlers in general. I
I'm currently having trouble getting example code for using tweepy to access Twitter's Streaming
I am currently having trouble with a live wallpaper that does some very intensive

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.