Author
|
Message
|
John Smith
|
Wednesday 14 December 2005 10:14:55 am
Hi there, Hope someone can help me. I just want to know how to fetch class name and class identifier in the templates. thanks.
|
Ole Morten Halvorsen
|
Wednesday 14 December 2005 11:05:39 am
Have you had a look at the fetch functions in the doc? http://ez.no/doc/ez_publish/technical_manual/3_6/reference/template_fetch_functions
To fetch a class see: http://ez.no/doc/ez_publish/technical_manual/3_6/reference/modules/content/fetch_functions/class If you already have a node or an object you don't have to fetch anything, eZ publish will do it for you. {$node.object.content_class|attribute(show)}
Senior Software Engineer - Vision with Technology
http://www.visionwt.com
http://www.omh.cc
http://www.twitter.com/omh
eZ Certified Developer
http://ez.no/certification/verify/358441
http://ez.no/certification/verify/272578
|
John Smith
|
Thursday 15 December 2005 12:56:01 am
hi ole, thanks for your kind help mate, very useful. One another thing if you can help. I want to fetch forum topic name in the forum reply template. Cheers.
|
Paul Forsyth
|
Thursday 15 December 2005 3:29:09 am
I think the forum topic is the parent of the reply, so: {$node.parent.name} should do it. Paul
|
John Smith
|
Thursday 15 December 2005 4:32:43 am
hi paul, thanks for your kind reply. Fetching parent node works fine for the forum reply while editing the forum reply, but that does not work while creating new forum reply. Because system is creating a new object id when you press new forum reply and there is no parent for that object id untill you click "send for publishiing" button. Am i right? If yes, how to fetch parent id means forum topic name or id while creating a new forum reply. Please help. cheers.
|
Paul Forsyth
|
Thursday 15 December 2005 4:52:21 am
According to: http://ez.no/doc/ez_publish/technical_manual/3_6/templates/the_pagelayout/variables_in_pagelayout You should be able to access $path or $content_info to find out where you currently are. From the path you can obtain the parent node id then consequently the parent node and its name. Paul
|
John Smith
|
Thursday 15 December 2005 5:12:55 am
hi paul, let me explain you the problem. what i am trying to do is to hide the subject input box in the forum reply page, because i dont want any subject every forum reply. I am also sending forum topic name as a hidden input field All the alteration are in \design\news\temlates\content\datatype\edit\ezstring.tpl. In that template i want to fetch forum topic name or id. I am not getting any thing. nothing from $path or $content_info. Editing a forum reply is working fine. I am using $attribute.object.main_parent_node_id. But using the same variable generates errors for new forum reply. Please help if you can. cheers.
|
Paul Forsyth
|
Thursday 15 December 2005 5:52:09 am
One thing about hiding attributes like this is you have to make two hidden input fields, eg:
{* Hide field *}
<input type="hidden" name="ContentObjectAttribute_data_text_{$attributes.item.id}" value="{$attributes.item.content.input.input_xml|wash( xhtml )}" />
<input type="hidden" name="ContentObjectAttribute_id[]" value="{$attributes.item.id}" />
where the item.id is your attribute id you want to hide. the second input is the important part here because the system expects an array of all attribute ids, so your hidden attribute must be accounted for. Because of this i would override and edit: design/standard/templates/content/edit_attribute.tpl instead of ezstring. It is a level higher than the ezstring edit template. Its then easier to use logic like:
{if eq($attributes.item.contentclass_attribute_name, "Somename")}
Show attribute
{else}
Hide attribute
{/if}
If you are trying the $path and $content_info variables at the ezstring level this might explain why they are empty. They will only be set in the top level content/edit.tpl. Paul
|
John Smith
|
Thursday 15 December 2005 6:35:01 am
hi paul, thanks for you kind help mate. I know i am wrong. the code i am doing is written pls have a look
{section name=ContentObjectAttribute loop=$content_attributes sequence=array(bglight,bgdark)}
<div class="block">
{* only show edit GUI if we can edit *}
{section show=and(eq($ContentObjectAttribute:item.contentclass_attribute.can_translate,0), ne($object.default_language,$ContentObjectAttribute:item.language_code) ) }
<label>{$ContentObjectAttribute:item.contentclass_attribute.name|wash}</label>
<div class="labelbreak"></div>
<input type="hidden" name="ContentObjectAttribute_id[]" value="{$ContentObjectAttribute:item.id}" />
{attribute_view_gui attribute_base=$attribute_base attribute=$ContentObjectAttribute:item}
</div>
{section-else}
<label{section show=$ContentObjectAttribute:item.has_validation_error} class="validation-error"{/section}>{$ContentObjectAttribute:item.contentclass_attribute.name|wash}</label>
<div class="labelbreak"></div>
<input type="hidden" name="ContentObjectAttribute_id[]" value="{$ContentObjectAttribute:item.id}" />
{if eq($ContentObjectAttribute:item.contentclass_attribute.name|wash, "Subject")}
<input type="hidden" name="ContentObjectAttribute_data_text_{$ContentObjectAttribute:item.id}" value="Re: New Forum" />
{ else }
{attribute_edit_gui attribute_base=$attribute_base attribute=$ContentObjectAttribute:item}
{/if}
</div>
{/section}
{/section}
I am confused mate, please help. I know what u saying is right. Can you please explain me where do the changes. I shall be very thankful to you. thanks.
|
Paul Forsyth
|
Thursday 15 December 2005 6:47:26 am
Thats close. Put the <input type="hidden" name="ContentObjectAttribute_id[]"... field into the if statement. What results are you getting?
|
John Smith
|
Thursday 15 December 2005 7:03:09 am
Paul, I think i dont need to put another line there, it above the if statement used for both case. The html output is given below have a look
<div class="block">
<label>Subject</label>
<div class="labelbreak"></div>
<input type="hidden" name="ContentObjectAttribute_id[]" value="1395" />
<input type="hidden" name="ContentObjectAttribute_ezstring_data_text_1395" value="Re: <Topic Forum Name>" />
</div>
<div class="block">
<label>Message</label>
<div class="labelbreak"></div>
<input type="hidden" name="ContentObjectAttribute_id[]" value="1329" />
<textarea class="box" name="ContentObjectAttribute_data_text_1329" cols="70" rows="10">
hi,this is new forum reply....
</textarea>
</div>
Please guide. Another thing paul how to fetch parent node for the forum reply...
|
Paul Forsyth
|
Thursday 15 December 2005 7:10:00 am
Ok, so does the forum reply submit for you now?
|
John Smith
|
Thursday 15 December 2005 7:14:45 am
Another thing paul how to fetch parent node for the forum reply... Another straight way function. Or do i need to use fetch statement.
|
Paul Forsyth
|
Thursday 15 December 2005 7:22:28 am
Try a quick test. See if $path or $content_info is present in: design/standard/templates/content/edit.tpl and also your current edit_attribute template. If its present in edit.tpl simply override it and change the include call to something like: {include uri="design:content/edit_attribute.tpl" path=$path} Paul
|
John Smith
|
Thursday 15 December 2005 7:33:48 am
I can't find any sort of "path" word in \desgin\standard\templates\content\edit.tpl. What to do? By the way thanks for continous help paul
|
Paul Forsyth
|
Thursday 15 December 2005 7:47:28 am
NP! What i meant was try something like {$path|attribute(show)}. But, ive just tried this locally and no go. However, this will work in your edit_attribute.tpl
{let parent=fetch(content,node,hash(node_id, $object.parent_nodes[0]))}
{$parent|attribute(show)}
{/let}
Now you have the parent you can take its name as normal. Paul
|
John Smith
|
Thursday 15 December 2005 7:52:34 am
that code is producing the output given below: Attribute Type Value nothing else.
|
John Smith
|
Thursday 15 December 2005 7:55:44 am
It is working. Means it giving the output which i was looking for. Thanks.
|
Paul Forsyth
|
Thursday 15 December 2005 8:01:56 am
Phew! Lovely :) Glad we got there in the end. Paul
|
John Smith
|
Thursday 15 December 2005 8:08:10 am
Hi Paul, Mate thanks for your kind help, Everything is working fine now. Really appreciated.. Keep helping ez community like Paul. Cheers.
|