Jump to content


Photo
- - - - -

Change excerpt length for post content feature slides


  • Please log in to reply
12 replies to this topic

#1 thniels

thniels

    Member

  • Members

  • 13 posts
  • LocationVarde, Denmark
  • Country: Country Flag

Posted 18 July 2012 - 12:15 PM

I have created a page that uses Features to show certain posts in a carousels fashion. The idea is that large monitors are set up in different departments, showing slides of blog posts of particular interest to them. Since the slides need to have the same content as the blog posts, it would be unnatural to use feature sets, however neat they are. Simply allowing post authors to check or uncheck a category in the post editor, and have their posts pop in and out of the monitors seems a user friendly approach. Everything is working wonderfully out of the box with a few css tweaks and a bit of javascript to keep the show automatically in-/excluding updated blog pages. Fairly few icy cows here. The problem is that the excerpt length cannot be changed with post content, leaving the slide shows with a meager 30 words and a More button. The global setting has no effect, btw. Can I change this excerpt length somehow?

p.s. The fact that the feature slider only accepts one post category will become an issue at some point but we can deal with that later.

#2 Rob

Rob

    One Smart Egg

  • Members
  • 13575 posts
  • LocationEast Coast, USA
  • Framework Version:The Latest, of course
  • Country: Country Flag

Posted 18 July 2012 - 05:01 PM

You need to create a filter in functions.php (in PageLines Customize plugin).
Here's the snippet to add:

Please Login or Register to see this Hidden Content


As for the category... you can apply one category to a feature set. If you want to have different author pages with different sliders per category, apply the category to a feature set.

#3 thniels

thniels

    Member

  • Members

  • 13 posts
  • LocationVarde, Denmark
  • Country: Country Flag

Posted 25 July 2012 - 12:40 PM

I tried doing this but it doesn't work. I entered this in the functions.php...

Please Login or Register to see this Hidden Content


...to have it only activate on a singular page, which indeed it does. The echo shows that at the front page the $length is 45 (as set in the Pagelines preferences) and at the Feature page it returns 9999 as expected. The excerpt, however, is unaffected. Letting the filter set $length regardless of page type, does affect the frontpage but not the Feature page. It appears that the Feature section disregards the excerpt_length setting altogether.

#4 catrina

catrina

    Advocate

  • Members
  • 12345 posts
  • LocationCalifornia
  • Country: Country Flag

Posted 25 July 2012 - 02:18 PM

I'm not an expert at PHP, unfortunately, but I think since Feature section is this one section on the page, the code would need to be tweaked to work for it.

#5 thniels

thniels

    Member

  • Members

  • 13 posts
  • LocationVarde, Denmark
  • Country: Country Flag

Posted 26 July 2012 - 12:46 PM

Catrina, you are right that it needs tweaking to work only for the Feature section and not affect other parts, but for testing purposes I am letting it affect all it can and the problem there is, that the Feature section does not appear to query the excerpt_length method but uses something else and thus the solution doesn't work. The method is being called, no doubt about that, for the echo statement is being executed. The return value, however, is not being used.

#6 Rob

Rob

    One Smart Egg

  • Members
  • 13575 posts
  • LocationEast Coast, USA
  • Framework Version:The Latest, of course
  • Country: Country Flag

Posted 26 July 2012 - 06:17 PM

Is there some reason why the code I provided earlier, which was correct as is, was edited in your application of it? We tested it as provided and it worked. Was there some compelling necessity to make it not work? Look at your edit. You've set the key number to 9999 with the change to 999. That's set up that the length is 9999, but that it has to change that to 999. LESS, not MORE Of course that's not going to work. I understand the desire to be creative, but if you're not expert in it, is it smart to change code?

#7 thniels

thniels

    Member

  • Members

  • 13 posts
  • LocationVarde, Denmark
  • Country: Country Flag

Posted 26 July 2012 - 08:49 PM

The change shown here was to show the simple echo statement - not showcase my coding skills. The code you provided worked *with post excerpts* but not with the excerpt length on Features. *That* is why I changed it. To rephrase my original question...

I have a Feature set up out of the box. Works splendidly. The Feature shows an excerpt of the blog post next to the picture. This excerpt length does not change. I am not talking about excerpts on the frontpage or anywhere else, where indeed your code *does* work.

I will check the code tomorrow when I am back in the office, to see where exactly the cropping takes place.

#8 thniels

thniels

    Member

  • Members

  • 13 posts
  • LocationVarde, Denmark
  • Country: Country Flag

Posted 27 July 2012 - 07:03 AM

This is what the Feature section does [sections/features/section.php @ line 448]...

Please Login or Register to see this Hidden Content



#9 thniels

thniels

    Member

  • Members

  • 13 posts
  • LocationVarde, Denmark
  • Country: Country Flag

Posted 27 July 2012 - 08:09 AM

This works (and has in fact been tested)...

Please Login or Register to see this Hidden Content


...but relies on excerpts not being used elsewhere inside Pages which is true in my case. Instead of is_page() it should check for being on a Feature page. Even better, have a setting on the Feature metapage.

#10 Danny

Danny

    Is Awesome!

  • Moderators
  • 15891 posts
  • LocationManchester, UK
  • Country: Country Flag

Posted 27 July 2012 - 09:11 AM

Hi Thomas, Has you issue been resolved or do you require further assistance?

#11 thniels

thniels

    Member

  • Members

  • 13 posts
  • LocationVarde, Denmark
  • Country: Country Flag

Posted 27 July 2012 - 10:18 AM

The problem at hand is dealt with but I consider the originally presented solution inadequate and the reply to my remarks to that effect inappropriate in so much as the fault was not in my changes to the example code but an oversight within the Feature section code (which you can easily verify by looking at your builds). In other words, the fault of Pagelines and not me. In this light remarks to my level of expertise is off the mark, which indeed any such remarks always are. Having paid for this product doesn't exactly help me accept this type of behaviour.

#12 Danny

Danny

    Is Awesome!

  • Moderators
  • 15891 posts
  • LocationManchester, UK
  • Country: Country Flag

Posted 27 July 2012 - 11:18 AM

Hi, In my opinion this isn't an issue with PageLines, this is simply the way our feature slider works. If you do not like the feature slider functionality, you're free to use create your very own slider or use another. I'm not quite sure what behaviour you're referring to, can you go into greater detail please.

#13 thniels

thniels

    Member

  • Members

  • 13 posts
  • LocationVarde, Denmark
  • Country: Country Flag

Posted 27 July 2012 - 12:26 PM

In my opinion this isn't an issue with PageLines


I completely understand. That is not, however, the impression I get when receiving a reply saying that what I was looking for is in fact doable and at the same time was presented with a solution. The solution didn't work (which is quite okay) and I commented on that, quite civilized I might add. The behaviour I am referring to, is the reply I was then met with...

Is there some reason why the code I provided earlier, which was correct as is, was edited in your application of it? We tested it as provided and it worked. Was there some compelling necessity to make it not work? Look at your edit. You've set the key number to 9999 with the change to 999. That's set up that the length is 9999, but that it has to change that to 999. LESS, not MORE Of course that's not going to work. I understand the desire to be creative, but if you're not expert in it, is it smart to change code?


I then went on to resolve the problem myself and did so. End of story. The Pagelines Frameworks is a brillant product and helped me save time on an internal project. To reiterate:

1) I ask a simple question
2) I get a perfectly good answer
3) I ask why it doesn't work as expected
4) I am pretty much told that it fails because I am stupid
5) I do what I should have done to begin with and browse the Feature Section code myself and upon realising that 2) is not even close, resolve the issue in a somewhat different manner and must then conclude that 4) is an invalid answer (not that it was acceptable in the first place)