I’m wondering if anyone has seen this… it’s really just an annoyance, I can work around it but..
I have created a partial ( called {edit_this} ) that draws a small “edit icon” to the screen if the user is logged in. It works correctly and I place it in each iteration of a channel entry so the person can edit directly from the Website (this is much like the add-on available for earlier versions of EE)
As I said, it works correctly however I have only 2 instances on my page where - for some reason - rather than the icon, it is printing the snippet name ittself to the screen with it’s curly braces.
These 2 instances are in an embedded footer, and in that footer are 3 other snippets that call various reuseable content and I have the “Edit_this” snippet inside of each of these other snippets. The first Snippet displays correctly, but the next two don’t.
If I take the Channel tag pair and it’s contents out of the misbehaving snippet & place it directly in the page, it works correctly, so I know it isn’t bad coding.
Has anyone noticed this or know why it may be acting this way?
Russ
Snippets inside of snippets aren’t actually supported, though they can work by happenstance if the snippets are named as such that the one that is contained inside the other one loads later. That’s relying on the alphabet and MySQL’s return order though and I wouldn’t recommend it—if ExpressionEngine changes how it accesses snippets, it could stop working.
Instead I would just use the {cp_edit_entry_url} as described here.
Thanks for the explanation… that {cp_edit_entry_url} seems pretty convenient, however I placed it (per the post you linked to) and it didn’t work. I used it as:
{if logged_in}
<a href="http://{cp_edit_entry_url}" class="" target="_blank" rel="noopener">_ <i class="fa fa-pencil-square-o"></i>_</a>
{/if}Is that not correct?
Russ
It shows the URL in the address bar as “http://stjacobsdev.org/?/cp/content_publish/entry_form” and displays (oddly) my about page.
I think the space where the question mark is should actually be “index.php?” but I am writing that out in the global preferences & my htaccess file.
In system/ee/legacy/libraries/channel_entries_parser/Parser.php around line 238 you should find:
$row['cp_edit_entry_url'] = ee('CP/URL',
'content_publish/entry_form',
array(
'site_id' => $row['site_id'],
'channel_id' => $row['channel_id'],
'entry_id' => $row['entry_id'],
),
TRUE
);Replace that with:
$row['cp_edit_entry_url'] = ee('CP/URL')
->make('publish/edit/entry/'.$row['entry_id'],
array(),
ee()->config->item('cp_url')
);Let me know if that works for you.
Worked like a charm… For anyone that finds this though, you may want to update your original code snippet that needs to be replaced with a ); at the end so it reads…
$row['cp_edit_entry_url'] = ee('CP/URL',
'content_publish/entry_form',
array(
'site_id' => $row['site_id'],
'channel_id' => $row['channel_id'],
'entry_id' => $row['entry_id'],
),
TRUE
);I wasn’t paying attention and missed that I had 2 closing parens at the end & it threw an error.
Thanks again.
Russ
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.