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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:07:41+00:00 2026-06-18T07:07:41+00:00

How to add a link category_id added to the admin? (Joomla 2.5) You could

  • 0

How to add a link category_id added to the admin? (Joomla 2.5)

You could write in the function JToolBarHelper::addNew('select.add'); or other functions…
For example,

index.php?option=com_pictures&view=select&layout=edit&category_id=14

Help, please. Thanks in advance

Reply David F:

Hi, David F. I almost got it.
After clicking “Add” appears category_id=14, and the rest did not work after clicking “Edit”, “Save”, “Save Close” … – category_id=0
I’ve been programming. Here’s an example:

...
protected $catid;

public function __construct($config = array()) {
    parent::__construct($config);

    if (empty($this->catid)) {
        $this->catid = JRequest::getInt('category_id', 0);
    }
}

protected function allowAdd($data = array()) {
    $user = JFactory::getUser();
    $categoryId = JArrayHelper::getValue($data, 'catid', JRequest::getInt('filter_category_id'), 'int');
    $allow = null;

    if ($categoryId) {
        $allow = $user->authorise('core.create', $this->option . '.category.' . $categoryId);
    }

    if ($allow === null) {
        return parent::allowAdd($data);
    } else {
        return $allow;
    }
}

protected function allowEdit($data = array(), $key = 'id') {
    $recordId = (int) isset($data[$key]) ? $data[$key] : 0;
    $categoryId = 0;

    if ($recordId) {
        $categoryId = (int) $this->getModel()->getItem($recordId)->catid;
    }

    if ($categoryId) {
        return JFactory::getUser()->authorise('core.edit', $this->option . '.category.' . $categoryId);
    } else {
        return parent::allowEdit($data, $key);
    }
}

protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') {
    $append = parent::getRedirectToItemAppend($recordId);
    $append .= '&category_id=' . $this->category_id;

    return $append;
}

protected function getRedirectToListAppend() {
    $append = parent::getRedirectToListAppend();
    $append .= '&category_id=' . $this->category_id;

    return $append;
}
  • 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-18T07:07:43+00:00Added an answer on June 18, 2026 at 7:07 am

    I believe that the functions that you are looking for are part of JController and should be added to your controller. In your case, this would likely be the select.php controller based on the view name in your url.

    You can see a good example of this in the categories component, specifically at administrator/components/com_categories/controllers/category.php.

    The following is the code in com_categories. You would want to rename extension to ‘category_id’ and may want to grab the value from JInput instead of the current class:

    /**
     * Gets the URL arguments to append to an item redirect.
     *
     * @param   integer  $recordId  The primary key id for the item.
     * @param   string   $urlVar    The name of the URL variable for the id.
     *
     * @return  string  The arguments to append to the redirect URL.
     *
     * @since   1.6
     */
    protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id')
    {
        $append = parent::getRedirectToItemAppend($recordId);
        $append .= '&extension=' . $this->extension;
    
        return $append;
    }
    
    /**
     * Gets the URL arguments to append to a list redirect.
     *
     * @return  string  The arguments to append to the redirect URL.
     *
     * @since   1.6
     */
    protected function getRedirectToListAppend()
    {
        $append = parent::getRedirectToListAppend();
        $append .= '&extension=' . $this->extension;
    
        return $append;
    }
    

    *EDIT:

    You also have to add it as part of the form. This is the easy, but important part. Just make sure the form has a hidden input with the value or add it to the url in the action section of the form:

    <form action="<?php echo JRoute::_('index.php?option=com_component&layout=edit&id='.(int) $this->item->id . '&category_id='.$this->category_id); ?>" method="post" name="adminForm">
    

    or use this:

    <input type="hidden" name="category_id" value="<?php echo $this->category_id; ?>" />
    

    To further explain what happens, when you click an item to go to the form, you likely add on the variable that you need. Then you add it to the form so that when one of the items is clicked, it will get submitted with the form. Joomla processes this form and either saves it or not depending on the toolbar button clicked. Then Joomla redirects, either back to the form or to the list view. Without the functions in your controller, your variable gets lost.

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

Sidebar

Related Questions

I'm trying to add column to ASPxGridView which would have link to other page:
I want to be able to add new sections (via the 'add' link) and
If i have img element id = myimg. Is posible to add link to
How would I add a link to my menu item in wxpython? What I
I want to add a link to a PDF file but instead of printing
I want to add a link to every image in the HTML with the
Am trying to add a link besides the Edit | Delete links in wordpress
I'd like to add a link to the end of some text that is
Recently I've found how to add a link to an item in Visual Studio
I am using preg_replace to add a link to keywords if they are found

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.