The default entity template shows an error:
Notice: Undefined variable: url in include() (line 35 of /....../modules/entity/entity.tpl.php).
My code that calls entity_view
is the following:
$block['content'] = entity_view('organization', $employers, 'user_employer', NULL, FALSE);
The issue is that entity.tpl.php
always expects the 'url' variable, but depending on if $page
is set in the original entity_view call, template_preprocess_entity
may not 'set' that variable up. There are a few places that this could be fixed, but I think it makes the most sense to just check for it in the tpl file.
There are a couple other issues raised in other modules that I believe are this exact issue:
#1553398: Undefined variable: url
#1561392: Undefined variable: url
Comment | File | Size | Author |
---|---|---|---|
#9 | entity-url-template-variable-1601162-9.patch | 846 bytes | tauno |
#3 | entity-check-url-in-entity-template-1601162-1.patch | 732 bytes | acrazyanimal |
#1 | entity-check-url-in-entity-template-1601162.patch | 728 bytes | acrazyanimal |
Comments
Comment #1
acrazyanimal CreditAttribution: acrazyanimal commentedComment #2
acrazyanimal CreditAttribution: acrazyanimal commentedComment #3
acrazyanimal CreditAttribution: acrazyanimal commentedCrud! messed up the commit message. Not that it really matters, but helps if you don't have to fix it up.
Comment #4
gmclelland CreditAttribution: gmclelland commentedThanks for posting this patch. I will try it out and see if it works.
Here is another related issue with EntityForm module:
#1491264: Notice when embedding the form with an Entity Reference Field
Comment #5
gmclelland CreditAttribution: gmclelland commentedThe patch in #3 applied but it didn't solve the problem with the issue posted in #4. I still get the same error message.
Comment #6
acrazyanimal CreditAttribution: acrazyanimal commented@gmclelland are you sure the patch applied. That should have fixed that particular problem. Check that the
entity.tpl.php
has the 'empty()
' check in the if statement on line 35.empty()
checks if the variable is set, so I don't see how you could still get that error if the patch did in fact apply?[EDIT] : I see what is going on here. There is a second error posted in comment #4 of the issue you posted in this issue's comment #4. It is an identical issue caused by the Entity forms module's copying of the entity api's template file. The issue is in entityform.tpl.php and is an entityforms module issue, not entity api. So, we'll deal with it there, not here.
Comment #7
mgifford#3: entity-check-url-in-entity-template-1601162-1.patch queued for re-testing.
Comment #8
Jelle_SPatch applies and solves the error.
Comment #9
tauno CreditAttribution: tauno commented@acrazyanimal I think the url needs to be set if entitiy_view() is called with $page = FALSE or NULL. The only time you don't need the url is if it's a full page view. Easiest solution is to move a couple lines of code in template_preprocess_entity().
I specifically ran into this bug using the rendered entity display formatter on an entityreference field where entityreference also sets $page to FALSE when calling entity_view().
Comment #10
yannickooPatch from comment #9 fixed the notice, thanks!
Comment #11
acrazyanimal CreditAttribution: acrazyanimal commented@tauno good call. Your patch makes more sense.
Comment #12
mgiffordJust checking that this is now in the repo and should thus be marked with a fixed status, right?
Comment #13
fagothanks #9 looks good, committed!