Posts: 524
Threads: 48
Joined: Mar 2011
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..
Posts: 1,204
Threads: 30
Joined: Jun 2010
2011-06-23, 22:46:47
(This post was last modified: 2011-06-23, 22:48:15 by BlackRose.)
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
Posts: 290
Threads: 26
Joined: Oct 2010
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>
Posts: 524
Threads: 48
Joined: Mar 2011
Thanks guys, I'll try things out.
Posts: 524
Threads: 48
Joined: Mar 2011
2011-06-24, 02:13:47
(This post was last modified: 2011-06-24, 02:19:36 by infos.media.)
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.
Posts: 1,204
Threads: 30
Joined: Jun 2010
2011-06-24, 02:14:23
(This post was last modified: 2011-06-24, 02:19:10 by BlackRose.)
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
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
Posts: 524
Threads: 48
Joined: Mar 2011
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);
Posts: 3,491
Threads: 106
Joined: Mar 2010
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.
Posts: 524
Threads: 48
Joined: Mar 2011
2011-06-24, 02:33:42
(This post was last modified: 2011-06-24, 02:42:36 by infos.media.)
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);
}
?>
Posts: 290
Threads: 26
Joined: Oct 2010
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
-Rob A>
Posts: 2,094
Threads: 54
Joined: Jan 2011
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.
Posts: 1,204
Threads: 30
Joined: Jun 2010
2011-06-24, 09:11:07
(This post was last modified: 2011-06-24, 09:30:32 by BlackRose.)
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
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
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
-Rob A>
don't be such a wiseass and help with bug hunting
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 !
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
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
Addons: blue business theme, Online Visitors, Notepad
Posts: 3,491
Threads: 106
Joined: Mar 2010
2011-06-24, 17:29:33
(This post was last modified: 2011-06-24, 17:31:22 by fotothink.)
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
Almost every field is cached/indexed, but not the page content (needed for the excerpt).
(anyway I didn't say anything abou another layer... :-?)
Posts: 524
Threads: 48
Joined: Mar 2011
2011-06-26, 22:08:17
(This post was last modified: 2011-06-26, 22:20:55 by infos.media.)
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.
Posts: 2,094
Threads: 54
Joined: Jan 2011
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)
|