Forums / Developer / variable not passing to filter_related

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

eZ debug

Timing: Jan 15 2025 04:44:26
Script start
Timing: Jan 15 2025 04:44:26
Module start 'content'
Timing: Jan 15 2025 04:44:27
Module end 'content'
Timing: Jan 15 2025 04:44:28
Script end

Main resources:

Total runtime1.8632 sec
Peak memory usage6,144.0000 KB
Database Queries216

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0073 684.3750214.7891
Module start 'content' 0.00731.6148 899.16411,975.6875
Module end 'content' 1.62210.2410 2,874.8516650.8906
Script end 1.8631  3,525.7422 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00720.3891210.0003
Check MTime0.00150.0784210.0001
Mysql Total
Database connection0.00080.044610.0008
Mysqli_queries1.739793.37132160.0081
Looping result0.00210.11082130.0000
Template Total1.825598.020.9127
Template load0.00480.256820.0024
Template processing1.820797.718120.9103
Template load and register function0.00110.058310.0011
states
state_id_array0.00150.079710.0015
state_identifier_array0.00140.075220.0007
Override
Cache load0.00460.2490640.0001
Sytem overhead
Fetch class attribute can translate value0.00150.083040.0004
Fetch class attribute name0.00220.1160140.0002
XML
Image XML parsing0.00130.071140.0003
class_abstraction
Instantiating content class attribute0.00000.0021210.0000
General
dbfile0.00110.0568260.0000
String conversion0.00000.000330.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
9content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
12content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
18content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
8content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 52
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs