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 7923579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:22:14+00:00 2026-06-03T17:22:14+00:00

Firstly, Kohana’s documentation is terrible, before people go read the docs I have read

  • 0

Firstly, Kohana’s documentation is terrible, before people go “read the docs” I have read the docs and they don’t seem to make much sense, even copying and pasting some of the code doesn’t work for some things in the documentation.

With that in mind, I have a route like so:

//(enables the user to view the  profile / photos / blog, default is profile)
Route::set('profile', '<userid>(/<action>)(/)', array( // (/) for trailing slash
    "userid" => "[a-zA-Z0-9_]+",
    "action" => "(photos|blog)"
))->defaults(array(
    'controller' => 'profile',
    'action' => 'view'
))

This enables me to go http://example.com/username and be taken to the users profile, http://example.com/username/photos to be taken to view the users photos and http://example.com/username/blog to view the blog.

If somebody goes http://example.com/username/something_else I want it to default to the action view for the user specified in <userid> but I can’t seem to find any way of doing this.

I could do it like this:

Route::set('profile', '<userid>(/<useraction>)(/)', array(
    "userid" => "[a-zA-Z0-9_]+",
    "useraction" => "(photos|blog)"
))->defaults(array(
    'controller' => 'profile',
    'action' => 'index'
))

then in the controller do this:

public function action_index(){
    $method = $this->request->param('useraction');
    if ($method && method_exists($this, "action_{$method}")) {
        $this->{"action_{$method}"}();
    } else if ($method) {
    // redirect to remove erroneous method from url
    } else {
        $this->action_view(); // view profile
    }
}

(it might be better in the __construct() function but you get the gist of it.)

I’d rather not do that though if there is a better method available (which there really should be)

I think the answer might be in the regex but the following does not work:

$profile_functions = "blog|images";
//(enables the user to view the images / blog)
Route::set('profile', '<id>/<action>(/)', array( 
            "id" => "[a-zA-Z0-9_]+",
            "action" => "($profile_functions)",
))->defaults(array(
    'controller' => 'profile'
));
Route::set('profile_2', '<id>(<useraction>)', array(
            "id" => "[a-zA-Z0-9_]+",
            "useraction" => "(?!({$profile_functions}))",
))->defaults(array(
    'controller' => 'profile',
    'action'     => 'view'
));

although it does match when nothing is after the ID.

  • 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-06-03T17:22:15+00:00Added an answer on June 3, 2026 at 5:22 pm

    I would set up the route like this:

    Route::set('profile', '<userid>(/<action>)(/)', array(
        "userid" => "[a-zA-Z0-9_]+",
        "action" => "[a-zA-Z]+"
    ))->defaults(array(
        'controller' => 'profile',
        'action' => 'index'
    ))
    

    And then in the controllers before() method:

    if(!in_array($this->request->_action, array('photos', 'blog', 'index')){
        $this->request->_action = 'view';
    }
    

    Or somethig similiar, just validate the action in the controller…

    EDIT:

    This could also work:

    if(!is_callable(array($this, 'action_' . $this->request->_action))){
        $this->request->_action = 'view';
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Firstly, Modifying may be the wrong term, I see a few people have posted
Firstly, please forgive me if I have asked this before (i suffer memory problems
Firstly, this seems like something that should have been asked before, but I cannot
Firstly, I am an absolute beginner in programming, so don't make fun of me
Firstly: I am totally a newbie for this kind of work. I have a
Firstly, I do not have any malicious intent out of this question. I would
Firstly, I'm not using rails. This is vanilla ruby application. I've read about packaging
Firstly, I have search Stack Overflow for the answer, but I have not found
Firstly, let me say that I've been on this issue for pretty much 2
Firstly, the title was the best I could come up with. I have written

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.