Jump to content

Update the templates to properly use $item->content()


teraßyte

Recommended Posts

Posted

As per title. I overloaded the \IPS\Content class to always parse some things inside the content for items, comments, reviews and so on but because you are not always using the content() or mapped('content') functions I cannot make it a global replacement. Unless I add a single exception for each application...

 

Here are some examples:

  • Downloads > front > view > view.phtml template: you use {$file->desc|raw}, which bypasses everything, instead of calling properly {$file->content()|raw}.
  • Calendar > front > view > view.phtml template: you use {$event->content|raw}, which bypasses everything, instead of calling properly {$event->content()|raw}.
  • Blog > front > view > view.phtml template: you use {$entry->content|raw}, which bypasses everything, instead of calling properly {$entry->content()|raw}.
  • Blog description: the blog description too is not treated as content for the actual blog item, instead it get returned differently based on the blog being group or member owned.
  • Cms Records: those don't use content() either, but I do see a different get__content() function for that. I guess I have to overload that manually myself since cms is kinda special?
  • I have not checked Gallery & Nexus but they are affected by the same issue most likely.

 

The only way I can see around the issue above right now would be to overload each application item class and add my own get_XXXX() function to return the proper value. Or am I missing something else?

 

 

P.S.: Can you please also take a look at those bug reports regarding the plugin upgrade process I posted for 4.1.6/7? They affect some of my paid modifications users... :p

Posted

Thinking about it I have a code hook on \IPS\Content and I wanted to add some hacks to work around this issue for now but what I came up with doesn't seem to work.

 

This is the code I added in my own hook (the code example is for downloads app - file description):

	// Fix downloads description
	public function get_desc()
	{
		return ( $this instanceof \IPS\downloads\File ) ? $this->content() : parent::__get('desc');
	}

I do a check with instanceof in order to change the behavior only for IPS apps and leave anything else the same.

 

I believe I got it to work once but after changing around some things it's not working anymore. The code above now returns NULL no matter what I do. I think I'll go to bed and try again in a few days when I have time, almost 1 AM and my brain isn't working properly anymore at this hour.

Posted

I sorted Downloads, Calendar, Blog, Gallery and Nexus (packages in the store).  CMS is special so yes, I would just override the second method.  Blog descriptions use a special get_description() method already (this is a little newer so perhaps you didn't notice it - if we're not using it properly somewhere let me know).

Posted
On 28/12/2015 at 4:10 PM, bfarber said:

I sorted Downloads, Calendar, Blog, Gallery and Nexus (packages in the store).  CMS is special so yes, I would just override the second method.  Blog descriptions use a special get_description() method already (this is a little newer so perhaps you didn't notice it - if we're not using it properly somewhere let me know).

Thanks for the update, I'll check out Blog and Cms.

 

Just to confirm, are the changes included for 4.1.6 or 4.1.7?

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...