Page 1 of 1

fetchPrintEntries and custom field

Posted: Thu Feb 26, 2009 10:07 am
by lordcoffee
Hi and Good morning!

I'm going to use "Featured News" Nugget in index.tpl. I'm using the

Code: Select all

{serendipity_fetchPrintEntries full=false fetchDrafts=false noSticky=true limit="0,5" template="featuredentries.tpl"}
Inside my featuredentries.tpl i have this

Code: Select all

{serendipity_hookPlugin hook="entries_header" addData="$entry_id"}
{foreach from=$entries item="dategroup"}
{foreach from=$dategroup.entries item="entry"}

{if $entry.properties.ep_featured}

<li class="clearfix">
											
<div class="sidebar-preview">
	<a href="{$entry.link}" rel="bookmark" title="Permanent Link to {$entry.title}">
		<img src="{$entry.properties.ep_postimage}" alt="{$entry.title}">
	</a>
</div>
<div class="sidebar-content">
	<a href="{$entry.link}" rel="bookmark" title="Permanent Link to {$entry.title}">{$entry.title}</a>
	<span><a href="{$entry.link}#comments" title="Read Comments">2 Comments</a></span>
</div>
</li>
{/if}
{/foreach}
{/foreach}
{serendipity_hookPlugin hook="entries_footer"}
It gives me all entries wich are using the custom field "featured".
My problem is the "limit="0,5" in FetchPrintEntries. It's just displaying the last 5 Entries and only if they're using the "featured" customfield. When I have for example 15 Entries and the first two and the last 2 use the "featured" customfield it only displays the first two because the last two are out of the range of "limit=0,5".

How can I get the last 5 "featured" entries?

Thanks in advance,
lordcoffee

Re: fetchPrintEntries and custom field

Posted: Thu Feb 26, 2009 10:19 am
by garvinhicking
Hi!

You need to use the advanced query features of that function, http://www.s9y.org/78.html (see "entryprops" parameter). With that you can immediately restrict all fetched entries to require a certain entryproperty field.

Regards,
Garvin

Re: fetchPrintEntries and custom field

Posted: Thu Feb 26, 2009 10:48 am
by lordcoffee
I don't know if I understood it right. Should it be like this when I enter true in the custom field?

Code: Select all

entryprops="ep_featured='true'"
Or is the output for every entry wich has any text inside this customfield?

Re: fetchPrintEntries and custom field

Posted: Thu Feb 26, 2009 10:52 am
by garvinhicking
Hi!
lordcoffee wrote:I don't know if I understood it right. Should it be like this when I enter true in the custom field?

Code: Select all

entryprops="ep_featured='true'"
Or is the output for every entry wich has any text inside this customfield?
Yeah, that should work. Have you tried it? Always try out things to see if they work, you can't really damage anything witha display function. :-)

Regards,
Garvin

Re: fetchPrintEntries and custom field

Posted: Thu Feb 26, 2009 11:16 am
by lordcoffee
garvinhicking wrote:Yeah, that should work. Have you tried it? Always try out things to see if they work, you can't really damage anything witha display function. :-)
Sorry that I didn't tell but yes, I've tried it and get no output.

Here is what I'm using in the index.tpl:

Code: Select all

{serendipity_fetchPrintEntries full=true fetchDrafts=false noSticky=true limit="0,5" entryprops="ep_featured='true'" template="featuredentries.tpl"}
and inside the featuredentries.tpl

Code: Select all

{serendipity_hookPlugin hook="entries_header" addData="$entry_id"}
{foreach from=$entries item="dategroup"}
{foreach from=$dategroup.entries item="entry"}

<li class="clearfix">
											
<div class="sidebar-preview">
	<a href="{$entry.link}" rel="bookmark" title="Permanent Link to {$entry.title}">
		<img src="{$entry.properties.ep_postimage}" alt="{$entry.title}">
	</a>
</div>

<div class="sidebar-content">
	<a href="{$entry.link}" rel="bookmark" title="Permanent Link to {$entry.title}">{$entry.title}</a>
	<span><a href="{$entry.link}#comments" title="Read Comments">2 Comments</a></span>
</div>

</li>

{/foreach}
{/foreach}
{serendipity_hookPlugin hook="entries_footer"}
The place where the output should be stays empty :?

EDIT:
Forget it ;-) I've figured out that I have to erase the ' s so that I have

Code: Select all

entryprops="ep_featured=true"

Thanks anyway!!!!

Re: fetchPrintEntries and custom field

Posted: Thu Feb 26, 2009 11:30 am
by garvinhicking
Hi!

Which s9y version are you using?

We need to do some debugging. Open your include/functions_smarty.inc.php file, go to around line 314 where you should find:

Code: Select all

        $entry = serendipity_fetchEntries(
            $params['range'],
            $params['full'],
            $params['limit'],
            $params['fetchDrafts'],
            $params['modified_since'],
            $params['orderby'],
            $params['filter_sql'],
            $params['noCache'],
            $params['noSticky'],
            $params['select_key'],
            $params['group_by'],
            $params['returncode'],
            $params['joinauthors'],
            $params['joincategories'],
            $params['joinown']
        );
After that, add the line:

Code: Select all

    if ($params['returncode'] == 'query') {
        return print_r($entry, true);
    }
and save the file. Then change your fetchprintentries call to:

Code: Select all

{serendipity_fetchPrintEntries full=true fetchDrafts=false noSticky=true limit="0,5" entryprops="ep_featured='true'" returncode="query"}
And then you should see a SQL query on your page. This is what I need. :-)

EDIT: Ah wait. I believe I've already found the bug. Try to use this instead:

Code: Select all

{serendipity_fetchPrintEntries full=true fetchDrafts=false noSticky=true limit="0,5" entryprops="ep_featured=true" returncode="query"}
Regards,
Garvin

Re: fetchPrintEntries and custom field

Posted: Thu Feb 26, 2009 11:33 am
by lordcoffee
:D :D :D

Sometimes it's so easy ;-)

Re: fetchPrintEntries and custom field

Posted: Wed Apr 22, 2009 9:58 pm
by lordcoffee
Hi! While I'm still porting magazeen (what is still hard to do for me ;-) ) I'm trying some codes on my own template (taeglichanders.de). I have featured entries done with a customproperties field called featured. If its "true" the entry is featured. I can already call all entries wich are featured=true as you can see when you press on "Alle features".

The big but:
I'm calling the featured entries with

Code: Select all

http://www.taeglichanders.de/blog/index.php?fullfeatureview=1
but when I want to add the feature of multiple languages it does not work anymore. I'm using

Code: Select all

<a href="?serendipity[lang_selected]=en">EN</a>
<a href="?serendipity[lang_selected]=de">DE</a>
So when I push the "DE" or "EN" it jumps back to the main page. When I'm watching the page in english and wwant to view the featured entries, all is back to german.

Any ideas how I can set the language to english or german and the blog remembers it?

Re: fetchPrintEntries and custom field

Posted: Thu Apr 23, 2009 11:01 am
by garvinhicking
Hi!

You would need to combine the parameters like ?fullfeatureview=1&serendipity[lang_selected]=de ?!?

Regards,
Garvin

Re: fetchPrintEntries and custom field

Posted: Thu Apr 23, 2009 1:57 pm
by lordcoffee
Yes, this will work but when I now would go to another category it changes back to the default language. Isn't this stored in a cookie? Or maybe I did something wrong ??? :lol:

Re: fetchPrintEntries and custom field

Posted: Thu Apr 23, 2009 1:58 pm
by garvinhicking
Hi!

I think it is only stored in a cookie when you use the languagechooser event plugin...don'T remember if that one has a config option...?

Regards,
Garvin

Re: fetchPrintEntries and custom field

Posted: Thu Apr 23, 2009 2:00 pm
by lordcoffee
OK, I'm goin to test this.

Thanks in advance Garvin!