Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Plugin to automagically display subpage excerpts?
#1
Hi,

is there a plugin which automagically searches for subpages and then outputs (configurable) excerpts for each subpage found? The "Pages Excerpt" plugin from Extend seems to only work for one, manually called, page..
Reply
#2
I was thinking about it some time ago, and you need only excerpt and navigation plugins (btw. Mvlcek's navi plug is brilliant)
Just adjust the code I use:
Code:
$siblings = return_i18n_menu_data(return_page_slug(), $minlevel=1, $maxlevel=2,$show=I18N_SHOW_NORMAL);
foreach ($siblings as $slugexcerpt)
echo  $slugexcerpt['title'].page_excerpt(''.$slugexcerpt['url'].'',200);
Addons: blue business theme, Online Visitors, Notepad
Reply
#3
Or excerpt and the n00dles pagecaching plugin which provides:
getChildren($page) - returns an array of slug names that are children of the given page

Untested code:
Code:
$children = getChildren(return_page_slug());
foreach ($children as $child)
  echo page_excerpt($child, 200);

-Rob A>
Reply
#4
Thanks guys, I'll try things out.
Reply
#5
yojoe Wrote:Just adjust the code I use:
Code:
$siblings = return_i18n_menu_data(return_page_slug(), $minlevel=1, $maxlevel=2,$show=I18N_SHOW_NORMAL);
foreach ($siblings as $slugexcerpt)
echo  $slugexcerpt['title'].page_excerpt(''.$slugexcerpt['url'].'',200);

Nice, this works almost out-of-the-box for me (it display siblings, not subpages, will mod that). Used DynPages to place it into the page and tweaked the title output by including headline. Showing it for other PHP-challenged users so they know how to add to the code:

Code:
echo  '<h2>'.$slugexcerpt['title'].'</h2>'.page_excerpt(''.$slugexcerpt['url'].'',200);

RobA Wrote:Or excerpt and the n00dles pagecaching plugin
Page Caching threw off News Manager last time I tried and it seems that neither plugin has been adapted.
Reply
#6
RobA: try with GS 3.1 and its builtin caching.
Didn't dig into it, but getting excerpts using builtin function will be way faster.

edit
Poly: I'm glad that there were no problems.
Adjusting is just a matter of taste, thus I posted only a raw code to get the data Wink

ps. make sure you get the right nested siblings as top lvl pages or parents may generate an error, thus may need some different vars when calling menu.
Addons: blue business theme, Online Visitors, Notepad
Reply
#7
This code is the shit. We have a tips'n'tricks section at get-simple.de with subpages and had to, until now, edit the parent page manually to include new sub pages for the overview (parent) page.

Making it work with our subpages is just a matter of

Quote:return_i18n_menu_data(return_page_slug(), $minlevel=2, $maxlevel=2,$show=I18N_SHOW_NORMAL);
Reply
#8
yojoe Wrote:RobA: try with GS 3.1 and its builtin caching.
Should work as is, same functions as PageCaching plugin :-)
yojoe Wrote:Didn't dig into it, but getting excerpts using builtin function will be way faster.
Nope, built-in function only gives the current page's excerpt.
Reply
#9
There's one nag though (isn't there always?) - quotes are escaped in the excerpt:

Code:
Navigations-\"Pfade\"

This can be fixed by modifying line 76 of pages-excerpts.php from

Code:
return '<p>' . $excerpt . '</p>';

to

Code:
return '<p>' . stripslashes($excerpt) . '</p>';

Here's my current version for others to grab:

Code:
<?php
$subpages = return_i18n_menu_data(return_page_slug(), $minlevel=2, $maxlevel=2,$show=I18N_SHOW_NORMAL);
foreach ($subpages as $slugexcerpt) {
echo  '<h2>'.$slugexcerpt['title'].'</h2>';
echo page_excerpt(''.$slugexcerpt['url'].'',200);
}
?>
Reply
#10
yojoe Wrote:RobA: try with GS 3.1 and its builtin caching.
Didn't dig into it, but getting excerpts using builtin function will be way faster.

Until I see the download link at the top of this page reads 3.1 I'll stick to 3.0 Wink

-Rob A>
Reply
#11
yojoe Wrote:
Code:
$siblings = return_i18n_menu_data(return_page_slug(), $minlevel=1, $maxlevel=2,$show=I18N_SHOW_NORMAL);

This function call works, but it also creates new variables $minlevel, $maxlevel and $show and assigns the parameter values to them, which could have side effects on other code.

The above function call should be better written as:
Code:
$siblings = return_i18n_menu_data(return_page_slug(), 1, 2, I18N_SHOW_NORMAL);

I suppose this is a result of simply giving a function definition like the following in the plugin description:
Code:
return_i18n_menu_data($slug, $minlevel=0, $maxlevel=0, $show=I18N_SHOW_NORMAL)
It tells you that the function has 4 parameters, where only the first one is required and the others will be 0, 0 and I18N_SHOW_NORMAL when they are not specified.
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply
#12
Carlos Wrote:Nope, built-in function only gives the current page's excerpt.
I didn't mean builtin GS excerpt function (I suggested implementind excerpt's plugin code), but builtin 3.1 caching plugin.
Since pages are cached, thus no need to use additional layer of caching Wink


polyfragmented Wrote:There's one nag though (isn't there always?) - quotes are escaped in the excerpt:

poly: http://get-simple.info/forum/post/14557/#p14557 Wink
I will address this matter to p01, but haven't seen him lately active.

RobA Wrote:
yojoe Wrote:RobA: try with GS 3.1 and its builtin caching.
Didn't dig into it, but getting excerpts using builtin function will be way faster.
Until I see the download link at the top of this page reads 3.1 I'll stick to 3.0 Wink
-Rob A>

don't be such a wiseass and help with bug hunting Tongue
Those moments when you see an exception, make WTFace, and go berserk - wanting to throw monitor outside the window and smash the keobard on the wall....
Priceless adventures with beta software ;D


mvlcek Wrote:
yojoe Wrote:
Code:
$siblings = return_i18n_menu_data(return_page_slug(), $minlevel=1, $maxlevel=2,$show=I18N_SHOW_NORMAL);
The above function call should be better written as:
[cut]
I suppose this is a result of simply giving a function definition like the following in the plugin description:

You wish that ! Tongue
This is a result of badly copy_pasted line from my clipboard manager.
As I mentioned earlier: Mvlcek is always here to nail the bugs !
thx once more for outstanding side features of your plugins Smile

Don't you think that Mvlcek's navi plugin should get into core and wipe out the builtin 1 lvl flat menu function ?
For me there's no problem, but newcomers ask how to build a dropdown menu, and they don't know (read as: didn't read features&requirements) it's impossible to do with base GS installation.



edit: (useful posts can't go without edit ?)
Forgot to mention that getting excerpts are a fantastic way of creating sitemaps with descriptions.
But getting them using navi plugin would be a killer on sites with many pages.
That's why GS 3.1 autocache feature comes in handy, but haven't looked nor on this feature, nor on the cached file structure. If somebody is willing to find it, I gladly see the solution Wink
Addons: blue business theme, Online Visitors, Notepad
Reply
#13
yojoe Wrote:I didn't mean builtin GS excerpt function (I suggested implementind excerpt's plugin code), but builtin 3.1 caching plugin.
Since pages are cached, thus no need to use additional layer of caching Wink

Almost every field is cached/indexed, but not the page content (needed for the excerpt).
(anyway I didn't say anything abou another layer... :-?)
Reply
#14
Got something related I need help with:

How can I catch the first paragraph of the pulled-in subpages?

We implemented the solution above, but I feel the user would benefit more if the complete first paragraph were output instead of some cut-off text. Since paragraph length varies, a fixed character number won't do.

Can this be achieved with PHP? I'm currently researching myself, but any help is appreciated.
Reply
#15
polyfragmented Wrote:Got something related I need help with:

How can I catch the first paragraph of the pulled-in subpages?

See the code in the Pagify plugin.
(it also checks the length, but if the size = 1 then it gets the first element, normally a paragraph)
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply




Users browsing this thread: 1 Guest(s)