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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T07:10:47+00:00 2026-05-16T07:10:47+00:00

I’m trying to use hook_menu to create a link to a view which takes

  • 0

I’m trying to use hook_menu to create a link to a view which takes an argument. However if I use the path (in $items[view-path/%dest]) that I’ve already set as the path in the view then the link doesn’t appear. I’m guessing there’s a path conflict somewhere. Is there a way round this? Or can I use another method to return the view?

I’m using the following code:

/**
* implementation of hook_menu().
*/

function sign_custom_menu() {
  $items['view-path/%dest'] = array(
    'title' => 'Link to view',
    'page callback' => 'sign_custom_hello',
    'page arguments' => array(1), //(corrected typo from 'page arguements')
    'access callback' => TRUE,
    'type' => MENU_NORMAL_ITEM,
    'menu_name' => 'menu-student-links',
  );

  return $items;
}

function dest_to_arg() {
  // would normally be dynamic to get view with correct argument
  $arg = 73;
  return $arg;
}

Thanks in advance.

Addition

function sign_custom_hello() {
    //return t('Hello!');
}
  • 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-16T07:10:48+00:00Added an answer on May 16, 2026 at 7:10 am

    I managed to answer my problem. Basically I used a different path to the one I had set in the view and then used views_page() as my “page callback”. I passed it the arguments for the view, the page ID and it’s own additional arguments to make the view work. I was able to use a wildcard in the menu item to pass to views_page() by using the to_arg() function that works with hook_menu() to pass in wildcards. The ‘page arguments’ pass in the three arguments. The last argument, “1” is a reference to which position in the path the argument appears (starting from 0).

    The working code is:

    <?php
    /**
    * implementation of hook_menu().
    */
    
    function sign_custom_menu() {
        $items['view-path/%dest'] = array(
            'title' => 'link to view',
            'page callback' => 'views_page',
            'page arguments' => array('view_name', 'page_1', 1),
            'access callback' => TRUE,
            'type' => MENU_NORMAL_ITEM,
            'menu_name' => 'menu-student-links',
        );
        return $items;
    }
    
    //this function is needed from the "%dest" argument in hook_menu above 
    
    function dest_to_arg() {
        // would normally be dynamic to get view with correct argument
        $arg = 73;
        return $arg;
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I'm trying to create an if statement in PHP that prevents a single post
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to select an H1 element which is the second-child in its group
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

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.