variable not passing to filter_related

Author Message

Carl Heaton

Monday 07 March 2005 3:17:42 am

if I replace 18 with:
$node.object.contentclass_id
or
$node.data_map.name.contentclass_attribute.contentclass_id
the script fails, placing 18 manually works perfectly
i've double and tripple checked $node.object.contentclass_id == 18

thnx in advance :)

{$node.data_map.name.contentclass_attribute.contentclass_id}
{let topic_articles=fetch( 'content', 'list', 
	hash(
		'parent_node_id', 58,
		'depth', 1,
		'class_filter_type', 'include',
		'class_filter_array',array('article_general')
		)
	)
}
<table width="100%" border="1">
	<tr>
		<th>Popular Articles for {attribute_view_gui attribute=$node.data_map.name}</th>
	</tr>
	{section loop=$topic_articles}
		{set topic_type=$node.object.contentclass_id}
		class:{$topic_type}<br />
		{set topic_article_relation=filter_related($:item.contentobject_id, 18, false)}
		{set topic_headline=$:item.data_map.headline}
		{set show_item=false}
		{section loop=$topic_article_relation}
			{section show=$:item.main_node_id|eq($node.main_node_id) }
				{set show_item=true}
			{section-else}
				{section show=$show_item|eq(false)}
					{set show_item=false}
				{/section}
			{/section}
		{/section}
		{section show=$show_item|eq(true)}
			<tr>
				<td>
					<strong><u>{attribute_view_gui attribute=$topic_headline}</u></strong><br/ >
				</td>
			</tr>
		{/section}
	{/section}
</table>

---
Carl
{'EZP 3.5, Apache 2, FC2, PHP 4.3.4 (cgi), MySQL 4.1.9'}

Łukasz Serwatka

Monday 07 March 2005 3:37:18 am

Hi

I suppose that you have declared var topic_type somewhere above...

What is the result of?

{let topic_type=''}
    {set topic_type=$node.object.contentclass_id}
    {$topic_type}
{/let}

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Carl Heaton

Monday 07 March 2005 3:51:37 am

Your sample code provided works fine. My code has been updated to the following but still with the issue $topic_type not getting passed to filter_related

Entire topic_articles.tpl:

{* $node.data_map.name.contentclass_attribute.contentclass_id *}
{let topic_type='' show_item=''}
    {set topic_type=$node.object.contentclass_id}
	{let topic_articles=fetch( 'content', 'list', 
		hash(
			'parent_node_id', 58,
			'depth', 1,
			'class_filter_type', 'include',
			'class_filter_array',array('article_general')
			)
		)
	}
<table width="100%" border="1">
	<tr>
		<th>Popular Articles for {attribute_view_gui attribute=$node.data_map.name}</th>
	</tr>
	{section loop=$topic_articles}
		class:{$topic_type}<br /> (* !!!NOTE!!! this outputs fine *}
		{let topic_article_relation=''}
			{set topic_article_relation=filter_related($:item.contentobject_id, $topic_type, false)} (* !!!NOTE!!! $topic_type doesn't seem to be passed *}
			{let topic_headline=''}
				{set topic_headline=$:item.data_map.headline}
				{set show_item=false}
				{section loop=$topic_article_relation}
					{section show=$:item.main_node_id|eq($node.main_node_id) }
						{set show_item=true}
					{section-else}
						{section show=$show_item|eq(false)}
							{set show_item=false}
						{/section}
					{/section}
				{/section}
			{/let}
		{/let}
		{section show=$show_item|eq(true)}
			<tr>
				<td>
					<strong><u>{attribute_view_gui attribute=$topic_headline}</u></strong><br/ >
				</td>
			</tr>
		{/section}
	{/section}
</table>
{/let}

Any further help is appreciated :)

---
Carl
{'EZP 3.5, Apache 2, FC2, PHP 4.3.4 (cgi), MySQL 4.1.9'}

Łukasz Serwatka

Monday 07 March 2005 4:03:04 am

Hi Carl,

Try with $:topic_type this looks like name space problem.
http://ez.no/ez_publish/documentation/development/libraries/ez_template/basics/namespaces

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Carl Heaton

Monday 07 March 2005 4:05:22 am

Update: Code has been tidied to cleanup set/let bad nesting. Problem still persists

{* $node.data_map.name.contentclass_attribute.contentclass_id *}
{let topic_type='' show_item='' topic_article_relation='' topic_headline=''}
    {set topic_type=$node.object.contentclass_id}
	{let topic_articles=fetch( 'content', 'list', 
		hash(
			'parent_node_id', 58,
			'depth', 1,
			'class_filter_type', 'include',
			'class_filter_array',array('article_general')
			)
		)
	}
<table width="100%" border="1">
	<tr>
		<th>Popular Articles for {attribute_view_gui attribute=$node.data_map.name}</th>
	</tr>
	{section loop=$topic_articles}
		class:{$topic_type}<br />
		{set topic_article_relation=filter_related($:item.contentobject_id, $topic_type, false)}
		{set topic_headline=$:item.data_map.headline}
		{set show_item=false}
		{section loop=$topic_article_relation}
			{section show=$:item.main_node_id|eq($node.main_node_id) }
				{set show_item=true}
			{section-else}
				{section show=$show_item|eq(false)}
					{set show_item=false}
				{/section}
			{/section}
		{/section}
		{section show=$show_item|eq(true)}
		<tr>
			<td>
				<strong><u>{attribute_view_gui attribute=$topic_headline}</u></strong><br/ >
			</td>
		</tr>
		{/section}
	{/section}
</table>
{/let}

---
Carl
{'EZP 3.5, Apache 2, FC2, PHP 4.3.4 (cgi), MySQL 4.1.9'}

Carl Heaton

Monday 07 March 2005 4:10:31 am

Hey Lucasz,

	{section loop=$topic_articles}
		class:{$:topic_type}<br />
		{set topic_article_relation=filter_related($:item.contentobject_id, $:topic_type, false)}

class:{$:topic_type} seems to output fine to the browser however the value still doesn't seem to pass to filter_related :-/

thanks again for your help thus far

---
Carl
{'EZP 3.5, Apache 2, FC2, PHP 4.3.4 (cgi), MySQL 4.1.9'}

Gabriel Ambuehl

Monday 07 March 2005 4:37:08 am

Are you using the newest filter_related version? On what version of ezP?

Visit http://triligon.org

Carl Heaton

Monday 07 March 2005 4:46:15 am

Hey Gabriel,
Yep, its the one you pointed me to via irc (gate|work) and its EZP3.5 :)

---
Carl
{'EZP 3.5, Apache 2, FC2, PHP 4.3.4 (cgi), MySQL 4.1.9'}

Gabriel Ambuehl

Monday 07 March 2005 4:54:41 am

Is topic type an int or a string?

You could try adding

eZDebug::writeError( "class:" $class );

on about line 95 of filterrelated.php (after

                $class = $namedParameters['class'];

and activate debugging to see what gets passed to the filter.

Or even better, uncomment line 104 for all params.

Visit http://triligon.org

Carl Heaton

Monday 07 March 2005 5:17:44 am

sorted :)

Looks like the `18` was getting passed as a string and as such the class got unset as the following was called:

		if(is_string($class)) {
			$class_instance=eZContentClass::fetchByIdentifier($class);
			$class=$class_instance->ID;
		}

In my version i've just commented out the offending if statement. Is there someway within the templating system to convert string->int etc?

---
Carl
{'EZP 3.5, Apache 2, FC2, PHP 4.3.4 (cgi), MySQL 4.1.9'}

Carl Heaton

Monday 07 March 2005 5:18:06 am

Almost forgot to say thnx very much to you both :)

---
Carl
{'EZP 3.5, Apache 2, FC2, PHP 4.3.4 (cgi), MySQL 4.1.9'}

Gabriel Ambuehl

Monday 07 March 2005 5:31:06 am

Interesting. I thought PHP would automatically figure this out correctly...

Visit http://triligon.org

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 31 2025 06:17:02
Script start
Timing: Jan 31 2025 06:17:02
Module start 'layout'
Timing: Jan 31 2025 06:17:02
Module start 'content'
Timing: Jan 31 2025 06:17:02
Module end 'content'
Timing: Jan 31 2025 06:17:02
Script end

Main resources:

Total runtime0.0136 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0052 588.2500151.2266
Module start 'layout' 0.00520.0025 739.476636.6641
Module start 'content' 0.00770.0046 776.1406110.2656
Module end 'content' 0.01230.0013 886.406349.9922
Script end 0.0136  936.3984 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002417.7383140.0002
Check MTime0.00107.6437140.0001
Mysql Total
Database connection0.00085.805910.0008
Mysqli_queries0.002518.025630.0008
Looping result0.00000.101610.0000
Template Total0.00107.410.0010
Template load0.00086.056410.0008
Template processing0.00021.308710.0002
Override
Cache load0.00064.223910.0006
General
dbfile0.00064.164380.0001
String conversion0.00000.059640.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs