Error with kinetic an 1.7 rc3

Found a bug? Tell us!!
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Error with kinetic an 1.7 rc3

Post by Timbalu »

I am not really sure on how to reproduce that behaviour you have...,

but you could first try and remove the backticks in
{pickKey array="`$entry`" key="`$template_option.ep_photo_large`" default='false'}

OR remove the reference in functions.inc.php line ~1168 from function &serendipity_pickKey(...) to function serendipity_pickKey(...) to see if that helps...,

OR it also might be the same issue judebert was talking about with these empty ep_* field,

OR it might be Smarty3 being picky about a parameter ['default'], as being a keyword.... (see default='false'})...

hmmm
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: Error with kinetic an 1.7 rc3

Post by Don Chambers »

Timbalu wrote:I am not really sure on how to reproduce that behaviour you have...,

but you could first try and remove the backticks in
{pickKey array="`$entry`" key="`$template_option.ep_photo_large`" default='false'}
That was the first thing I tried - didn't make any difference.
Timbalu wrote:OR remove the reference in functions.inc.php line ~1168 from function &serendipity_pickKey(...) to function serendipity_pickKey(...) to see if that helps...,
Why? I did try this, but it made no difference.
Timbalu wrote:OR it also might be the same issue judebert was talking about with these empty ep_* field,
That was an observation relating to quicksearch. The value of the extended property field stored in a template option is correct - ie ep_LargeImage.
Timbalu wrote:OR it might be Smarty3 being picky about a parameter ['default'], as being a keyword.... (see default='false'})...
This also seems correct - the values of {$img} (assigned in the capture) are all 'false'... or whatever word I use as the default (I tried changing default='false' to default='test', and pickKey returned 'test'). This default value is supposed to be returned if the specified key is not found... but the contents of the array look the same to me in 1.6.2 and 1.7 - yet something with pickKey is not working.
=Don=
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: Error with kinetic an 1.7 rc3

Post by Don Chambers »

I tried a few more things - we know that pickKey is valid, because otherwise it would trigger an "unknown tag" error... but I am still stuck.
=Don=
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Error with kinetic an 1.7 rc3

Post by Timbalu »

Well, yes ... but I meant judebert was talking about the value of the property, so what is ep_LargeImage (property or value)?

Same on the last - vice versa, I meant Smarty3 maybe being picky about the default word, not its value.
So maybe .. {pickKey array=$entry key=$template_option.ep_photo_large ret='false'}

I am just guessing in the blue, since I don't know how to set up something reproducable here...
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: Error with kinetic an 1.7 rc3

Post by Don Chambers »

ep_LargeImage is an extended property field that contains the path to an image in the media library. The name of the extended property field is correct. The path is correct.

"ret" vs. Default does not work.

Remember, this has all worked just fine for the last 3-4 years. I'm beginning to wonder if it is not pickKey at all, but rather something about the array.
=Don=
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Error with kinetic an 1.7 rc3

Post by Timbalu »

What about the capture syntax..?
http://www.smarty.net/docs/en/language. ... apture.tpl

It says the name attribute is required!
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: Error with kinetic an 1.7 rc3

Post by Don Chambers »

Timbalu wrote:What about the capture syntax..?
http://www.smarty.net/docs/en/language. ... apture.tpl

It says the name attribute is required!
I saw that last night. Tried it, made no difference. EDIT: I should have also said that capture works fine - it is properly capturing the default of 'false' into $img.
=Don=
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Error with kinetic an 1.7 rc3

Post by Timbalu »

Sh...! Then you need to debug the hard way.
First try to trigger the errors in include/functions_smarty.inc.php line ~645
in function serendipity_smarty_pickKey($params, &$smarty) {
to surely know they are working as intended,
then follow the $param array with some debugging output, until ending up in your tpls with <pre>{$entry|print_r}</pre> and <pre>{$template_option|print_r}</pre>
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Error with kinetic an 1.7 rc3

Post by Timbalu »

This works

Code: Select all

{pickKey array=$entry key="ep_access" default='false'}
throwing 'public'. :)

$entry is an array - if you put it in quotes it will be interpreted as a string.

As of now this should work. Maybe you'll need to remove the quotes for key too

Code: Select all

{pickKey array=$entry key="$template_option.ep_photo_large" default='false'}
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: Error with kinetic an 1.7 rc3

Post by Don Chambers »

Timbalu wrote:This works

Code: Select all

{pickKey array=$entry key="ep_access" default='false'}
throwing 'public'. :)

$entry is an array - if you put it in quotes it will be interpreted as a string.

As of now this should work. Maybe you'll need to remove the quotes for key too

Code: Select all

{pickKey array=$entry key="$template_option.ep_photo_large" default='false'}
Came here to tell you the exact same thing... quotes and backticks need to be removed from both array and key. Odd because backticks were specifically required this was first developed.

Still have other things that are not working, and need to see if this change is backwards compatible.
=Don=
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: Error with kinetic an 1.7 rc3

Post by Don Chambers »

Actually, I stand corrected - YOUR solution was the correct one. Kudos! :wink:
=Don=
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: Error with kinetic an 1.7 rc3

Post by Don Chambers »

I have run into a bit of of a problem. Two actually, but they are related: passing values from one tpl to another.

I have a tpl named content_fullbox.tpl. Within that tpl is a foreach loop, and within that loop, category specific entries are fetched using a specific template:

Code: Select all

{foreach from=$fullboxes item="fullbox" name=categoryboxes}
    {serendipity_fetchPrintEntries template="entries_fullbox.tpl"}
{/foreach}
$fullboxes contains $fullbox.catid, $fullbox.title, etc. Prior to 1.7, these values were available in this "parent" tpl *AND* the tpl used by fetchPrintEntries. The parent content_fullbox.tpl also had variables defined, such as {assign var='foo' value='bar'} - these too were available in the template called by fetchPrintEntries. In both cases, these are no longer available in what I am referring to as a child template, though that may not be the correct definition.

I see "assign" has attributes of parent, root and global. None of these are what I seem to need. Any suggestions on how to replicate what was working fine in smarty 2?! :roll:
=Don=
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Error with kinetic an 1.7 rc3

Post by Timbalu »

Code: Select all

{foreach from=$fullboxes item="fullbox" name=categoryboxes}
    {serendipity_fetchPrintEntries template="entries_fullbox.tpl" }
{/foreach}
Is there really a need to use serendipity_fetchPrintEntries here?
Why not a plain include? This could hold a scope="parent" and even go with a flag inline, to merge the compile code of the subtemplate into the compiled calling template.

Code: Select all

{include file='sub_template.tpl' scope="parent" inline}
The assign should do with adding a scope something and, if using the include, in both even without (IMO), since display variables are assigned to sub_templates automatically too and the falldown assignment hasn't changed with Smarty3. The inheritance tree changed from S2 to S3 from scope root to scope template. (*) So this only has to be remembered. Did you test the available scopes?

If all that won't do, we have a bigger problem, possibly while having to add a template inheritance option to cores fetchPrintEntries. To check this out you could send me your dev work to have some more practical testing examples.

(*) That is why we had to do this in that other thread, while (in that special case) it looked like a sub_template, but was a parent (for Smarty) in real.
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: Error with kinetic an 1.7 rc3

Post by Don Chambers »

{include} is not going to work - I need serendipity_fetchPrintEntries to use parameters such as which category to fetch, how many entries to fetch, include/exclude duplicates, etc, all outlined on this page.

{assign} (without any defined scope) does not work in my tests with serendipity_fetchPrintEntries. Perhaps the attribute of template=entries_fullbox.tpl is not seen as a sub template?

Within the content*.tpl file, a foreach loop processes a particular box's saved options, such as "truncated quantity" and "titles only quantity". A few of these values are converted to variables via {assign}. These variables had previously been available to the entry template (ie entries_fullbox.tpl), but no longer are available. I'm not sure why I created variables out of them in the first place - I can probably live without that as long as I can get this next piece to work..

I addition to those variables passing to the fetched entry template (entries_fullbox.tpl), the values in the foreach loop, such as $foreach.truncated_qty (for the truncated quantity) also passed to that fetched template... ie, I could reference $foreach.truncated_qty in entries_fullbox.tpl AND the parent content_fullbox.tpl which contains the foreach loop. Now, I cannot see these values in entries_fullbox.tpl. I need these $foreach.VALUES to be inherited by the fetch entry template, as they previously were. I can probably set each foreach value to a variable, then use either a root or global scope, but I would prefer not to as my instinct tells me this merely uses more memory.
=Don=
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

Re: Error with kinetic an 1.7 rc3

Post by Timbalu »

Well I was apprehensive that it wouldn't be so easy... ;-)
If I understand this correct, we now have the problem that the template and its variables fetched via

Code: Select all

{serendipity_fetchPrintEntries template="foo.tpl"}
are not in the scope of $CONTENT which is $entries, calling this, since living in its own context. If included by {include} it would naturally chain into that calling same template inheritance object...
Are there any more templates which do this the same way?
Now we have to find a way to overrule this on demand.

Don, could you find out if this little tweak (just a temporary workaround check) does help. Find the include/functions_smarty.inc.php file and in there the

Code: Select all

function &serendipity_smarty_fetch($block, $file, $echo = false) 
There you see this:

Code: Select all

$output = $serendipity['smarty']->fetch('file:'. serendipity_getTemplateFile($file, 'serendipityPath'), null, null, null, ($echo === true && $serendipity['smarty_raw_mode']));
and try to change the third null parameter to 'parent' or 'root' and if that does not work even to 'global', in this order, i.e.

Code: Select all

$output = $serendipity['smarty']->fetch('file:'. serendipity_getTemplateFile($file, 'serendipityPath'), null, null, 'parent', ($echo === true && $serendipity['smarty_raw_mode']));
PS. Having my own playground with this would be much easier...(hint!) ;-)

Edit:
Arrgh! That will possibly error since we would need the parent object here... then try

Code: Select all

$output = $serendipity['smarty']->fetch('file:'. serendipity_getTemplateFile($file, 'serendipityPath'), null, null, null, ($echo === true && $serendipity['smarty_raw_mode']), true);
which should normally be already the default, set to true, telling to merge parent template variables in to local scope ... now, how did you do fix this problem by assign exactly and how was the scope of included templates?
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian
Post Reply