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

  • Home
  • SEARCH
  • 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

I'm trying to get my head around to understand how to use closures in
I'm currently researching MongoDb as a possible database option, and I'm having trouble dealing
I am having trouble with a single Wcf Service that we have in an
Maybe I have a bad design but I am currently trying to get an
We're currently having a debate whether it's better to throw faults over a WCF
I'm currently having a major issue with a python script. The script runs arbitrary
I am currently having a hardtime understanding and implementing events in C# using delagates.
I'm currently having a problem with a ShoppingCart for my customer. He wants to
I am currently having some problems with <li> in IE6 essentially my code looks
Hopefully someone can shed a little light on an issue that I'm currently having

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.