Skip to content

Commit

Permalink
Fix link for tag in breadcrumbs
Browse files Browse the repository at this point in the history
  • Loading branch information
battye committed Jan 29, 2024
1 parent c3ce74e commit 04b74ed
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 9 deletions.
10 changes: 9 additions & 1 deletion controller/manage/queue/item.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ public function display_item($id)
return $this->helper->needs_auth();
}

// Create type link information for tags (e.g., make sure the tag hyperlinks back to the type)
$queue_type = $this->types->get($this->queue->queue_type);
$queue_type_name = $queue_type->name;
$queue_type_url = $queue_type->url;

// Display the main queue item
$data = \queue_overlord::display_queue_item($this->id);

Expand All @@ -96,11 +101,14 @@ public function display_item($id)

$tag = $this->request->variable('tag', 0);

// Make sure the item category is added to the breadcrumb.
// If the user clicks on a tag (e.g., a tag like "New" or "All")
// then this part ensures it gets added to the navigation breadcrumbs
if ($tag)
{
// Add tag to Breadcrumbs
$this->display->generate_breadcrumbs(array(
$this->tags->get_tag_name($tag) => $this->queue->get_url(false, array('tag' => $tag)),
$this->tags->get_tag_name($tag) => $this->queue->get_url(false, array('tag' => $tag), [$queue_type_name => $queue_type_url]),
));
}

Expand Down
1 change: 1 addition & 0 deletions controller/manage/queue/queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ public function display_queue($queue_type)

// Add to Breadcrumbs
$this->display->generate_breadcrumbs(array(
// This is where the type gets displayed
$this->type->lang['lang'] => $this->get_queue_url($this->type->id),
));

Expand Down
31 changes: 23 additions & 8 deletions includes/objects/queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -668,20 +668,35 @@ public function get_queue_discussion_topic($check_only = false)
*
* @param bool|string $action Optional action to link to.
* @param array $params Optional parameters to add to URL.
* @param array $tag Optional link to type if tags shown
*
* @return string Returns generated URL.
*/
public function get_url($action = false, $params = array())
public function get_url($action = false, $params = array(), $tag = false)
{
$controller = 'phpbb.titania.queue.item';
$params += array(
'id' => $this->queue_id,
);
if (!$tag)
{
$controller = 'phpbb.titania.queue.item';
$params += array(
'id' => $this->queue_id,
);

if ($action)
{
$controller .= '.action';
$params['action'] = $action;
}
}

if ($action)
else
{
$controller .= '.action';
$params['action'] = $action;
// Link back to the correct type if the tag is shown
$type_name = array_key_first($tag);

$controller = 'phpbb.titania.queue.type';
$params += [
'queue_type' => $tag[$type_name],
];
}

return $this->controller_helper->route($controller, $params);
Expand Down

0 comments on commit 04b74ed

Please sign in to comment.