I've checked the option " Allow the use of PHP to set titles and paths " but the php code I've used in the custom breadcrumb is not evaluated.

When I view a node, I see the php string (inside ) on the breadcrumb.

In the "title" section I've set:

[field_custom-title]

This is the code I've used in the path:

<?php $user_content_profile = content_profile_load('userprofile', [author-uid]); return array('people/' . $user_content_profile->nid ); ?>

It is in only one line, otherwise I cannot save the breadcrumb due to another bug: there is an error message:
# Every link path must have a matching title. There are 4 paths, and 1 titles.

I've even tried to put the php code all in the title field:

<?php
$user_content_profile = content_profile_load('userprofile', [author-uid]);
return array('[field_custom-title]|people/' . $user_content_profile->nid );
?>

But even this prints the php code instead of evaluating it.

I've reproduced the bug in both -beta2 and 6.x.2.x-dev.

CommentFileSizeAuthor
#1 701902_remove_php_validate.diff2.71 KBMGN

Comments

MGN’s picture

Version: 6.x-2.0-beta2 » 6.x-2.x-dev
Assigned: Unassigned » MGN
Status: Active » Needs review
StatusFileSize
new2.71 KB

Looks like we should not try to validate the number of titles and paths if php is being used to set the breadcrumb titles or paths. Its causing more trouble than its preventing.

Here is a patch which removes the validation code when php is being used...it would be a great help if you could test it on the latest 6.x.2.x-dev and see if it helps.

finex’s picture

I've temporary removed the breadcrumb yesterday :-) :-) :-) :-)

I'll check the patch later... thanks :-p

finex’s picture

I've tried the patch, now I can enter the PHP code only in the title field without the line checking error, but it is not evaluated :-(

MGN’s picture

Status: Needs review » Postponed (maintainer needs more info)

If you are entering the php code for both titles and paths within the title field, then you need to return an array like this:
Titles:

<?php return array('titles' => array('Title1', 'Title2', '[title]'), 'paths' => array('path1','path2', 'node/[nid]')); ?>

In this case you would leave the paths field on the form blank. Also, be sure you are including the php tags (it seems like you are).

If you are entering the php code separately in the titles and paths, then it would be like

Titles:

<?php return array('Title1', 'Title2', '[title]'); ?>

Paths:

<?php return array('path1','path2', 'node/[nid]'); ?>

The only reason that I can think of for the code not to be evaluated would be if the first 5 characters of the titles and paths field were not "<?php".

If you are using something like fckeditor or another wysiwyg editor, be sure that you turn it off for these fields (switch to plain text) so it is not inserting paragraph tags or other html before the php tags (you would see these html tags stored in the custom breadcrumbs database tables).

Hopefully its something like this. Otherwise, include your titles and paths field exactly as they appear for your breadcrumb using the format that I did above, and I'll have another look.

marrch_caat’s picture

The patch works OK, thank you. I'd suppose applying it to the dev branch and including in the next release.

MGN’s picture

Status: Postponed (maintainer needs more info) » Reviewed & tested by the community

Marking this as RTBC based on the comments of marrch_caat and FiNeX. FiNeX, if you are still having issues with php code evaluation, please see #4 above and provide more information to allow others to help troubleshoot.

MGN’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 6.x-2.x-dev http://drupal.org/cvs?commit=334740

Status: Fixed » Closed (fixed)

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

Equinger’s picture

I'm having this problem and I'm pulling my hair out. Really want/ need for this function to work so I'm committed to fixing it and appreciate the ability to do this at all, but I think there's a legitimate problem ... I'm using plain text and the most simplified php possible for proof of concept and it won't evaluate ... outputting the code as a string as described above.

I also have been playing around with returning TRUE or ignoring the 'Breadcrumb visibility' field and that impacts whether a breadcrumb is displayed at all. If TRUE nothing displays.

MGN’s picture

@Equinger,

Please open a new issue so we can troubleshoot this. In the new issue give all the details for how you have setup your custom breadcrumb, including visibility, titles and paths (what php code are you using?). Are you sure the php code is correct and returning an array of titles/paths? Also, what type of custom breadcrumb (node, views, paths, taxonomy, etc.) and on what type of pages is it not working. With that information I should be able to help.

Thanks

Equinger’s picture

Alright ... I figured out the deal that myself and others are having in this current version. haha - surprisingly fast for being pretty frustrated 10 mins ago or whatever it was.

If you are having a problem with this, it's because your code is on multiple lines so Custom Breadcrumbs acts as though it is a string on each line and the php is never evaluated.

Perhaps Custom Breadcrumbs could put the code on a single line if it detects php.

Equinger’s picture

Thanks for looking at this so quick MGN! Really appreciate that, but I'm pretty sure what I described is the problem people are having ... presumptuous, perhaps.

MGN’s picture

Can you give an example of your php code that didn't work, and then show how you corrected it?