We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

EE 3.0.4 - Snippet misbehaving (maybe?) in certain instances

How Do I?

Russ K.'s avatar
Russ K.
174 posts
10 years ago
Russ K.'s avatar Russ K.

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

       
Derek Jones's avatar
Derek Jones
7,561 posts
10 years ago
Derek Jones's avatar Derek Jones

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.

       
Russ K.'s avatar
Russ K.
174 posts
10 years ago
Russ K.'s avatar Russ K.

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

       
Derek Jones's avatar
Derek Jones
7,561 posts
10 years ago
Derek Jones's avatar Derek Jones

What’s the full context, is that inside a Channel Entries tag? And what version of ExpressionEngine are you running?

       
Russ K.'s avatar
Russ K.
174 posts
10 years ago
Russ K.'s avatar Russ K.

Yes. It is inside a channel entries tag & I’m on EE 3.0.4 - Sorry, should have mentioned that.

Thanks. Russ

       
Derek Jones's avatar
Derek Jones
7,561 posts
10 years ago
Derek Jones's avatar Derek Jones

Can you specify how it’s not working? Is it not outputting, is it outputting the wrong thing? Outputting but the link not taking you to the right place?

       
Russ K.'s avatar
Russ K.
174 posts
10 years ago
Russ K.'s avatar Russ K.

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.

       
Derek Jones's avatar
Derek Jones
7,561 posts
10 years ago
Derek Jones's avatar Derek Jones

Hm, should be using your system URL not your front end URL. I’ll file a bug and post back here with a solution.

       
Russ K.'s avatar
Russ K.
174 posts
10 years ago
Russ K.'s avatar Russ K.

OK. Thanks for looking at it.

Russ

       
Russ K.'s avatar
Russ K.
174 posts
10 years ago
Russ K.'s avatar Russ K.

Derek, One additional thing that may matter that I just noticed… the reason my “about” page is showing is because that is what my 404 Page is set to in Template settings.

Russ

       
Derek Jones's avatar
Derek Jones
7,561 posts
10 years ago
Derek Jones's avatar Derek Jones

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.

       
Russ K.'s avatar
Russ K.
174 posts
10 years ago
Russ K.'s avatar Russ K.

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

       
Derek Jones's avatar
Derek Jones
7,561 posts
10 years ago
Derek Jones's avatar Derek Jones

Fixed. Knew I should have just went for a nap after shoveling snow all day!

       
Russ K.'s avatar
Russ K.
174 posts
10 years ago
Russ K.'s avatar Russ K.

Ughh… no snow here yet in sunny Ohio LOL

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.