Hi again,

_twitter_bootstrap_local_tasks is a cool function to theme the primary nav. However, it doesn't seem to want to take dynamic paths (paths with a % character).

I thought we take that into account. Especially useful for access functions.

Old

/**
  * Get all primary tasks including subsets
  */
function _twitter_bootstrap_local_tasks($tabs = FALSE) {
  ...
  $router_item = menu_get_item($element['#link']['path']);

with

New

  $path_components = explode('/', $element['#link']['path']);
  foreach($path_components as $position => $component) {
    // See if % is the first character.
    if (strpos($component, '%') === 0) {
      $path_components[$position] = arg($position);
    }
  }
  
  $path = implode('/', $path_components);
  $router_item = menu_get_item($path);

Don't know if you want patches or not, but I'm happy to start contributing them if you are.

Comments

nagiek’s picture

Oh yeah, and this fix doesn't handle menu_default_local_task paths. Working on that.

nagiek’s picture

Well, you can just do the same thing later on I guess.

if ($i === 0) {
  $item['href'] = $item['tab_parent'];

to

if ($i === 0) {
  $path_components = explode('/', $item['tab_parent']);
  foreach($path_components as $position => $component) {
    // See if % is the first character.
    if (strpos($component, '%') === 0) {
      $path_components[$position] = arg($position);
    }
  }
  $item['href'] = implode('/', $path_components);
}

I'm feeling the bloat, however. Is there an existing function to do this? Or should we be comparing ['href'] instead of ['path']?

kalabro’s picture

Assigned: frankbaele » Unassigned
StatusFileSize
new9.22 KB
new1.04 KB

This bug also produces

PDOException: SQLSTATE[22P02]: Invalid text representation ... in DrupalDefaultEntityController->load() (line 196 of /.../includes/entity.inc).

...for node/%node, user/%user pages.
May be related to #1003788: PostgreSQL: PDOException:Invalid text representation when attempting to load an entity with a string or non-scalar ID.

I suggest a patch, which works for:
Drupal 7.14
Twitter bootstrap 7.x-2.x-dev
PostrgeSQL and MySQL

frankbaele’s picture

Assigned: Unassigned » frankbaele
Status: Active » Needs review

i will test it

Renee S’s picture

Assigned: Unassigned » frankbaele

This patch worked for me - I was getting some crazy entityAPI errors and finally tracked it down to this. I'm using OG and Spaces, with Persistent URL.

Edited to add: it's not quite fixed everything, I'm still getting an error with my Features Config page for Spaces OG... basically the theme doesn't render and I get an unstyled page that chops off after the menu. It has a form item that queries pURL to allow you to set the homepage path.

Renee S’s picture

Status: Needs review » Needs work

This also fails with Panels in-place editor.

skriptble’s picture

This patch worked for me too. I was getting an annoying Entity API error with Invalid Data Value Given.

wundo’s picture

Assigned: frankbaele » Unassigned
Status: Needs work » Needs review
StatusFileSize
new1.2 KB

Ok, I'm rerolling kalabro's patch from 3.
It's working for me.

vulfox’s picture

So does it work or not? Renee says it doesn't don't you others have similar problems then?

wundo’s picture

Status: Needs review » Fixed

Vulfox, it does fixes the issue for dynamic paths, I'm unable to test it with panels, if there is still a issue when using panels please open a new issue, marking this one as fixed (I've just committed the fix to the main branch)

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

andregriffin’s picture

Project: Twitter's Bootstrap » Bootstrap