eZpedia : Snippets https://ezpedia.org Source code snippets on eZpedia es-ES Template logic and settings to provide rounded corners on image aliases https://ezpedia.org/snippet/template_logic_and_settings_to_provide_rounded_corners_on_image_aliases https://ezpedia.org/snippet/template_logic_and_settings_to_provide_rounded_corners_on_image_aliases <a name="eztoc160429_1" id="eztoc160429_1"></a><h2>Abstract</h2><p>Image processing is a very powerful feature of eZpublish. This article shows you how to combine 24 bit PNG images with ImageMagick via the eZpublish image alias system, and to produce images with pre-rendered rounded corners.</p><a name="eztoc160429_2" id="eztoc160429_2"></a><h2>Approaches</h2><p>There are a number of ways of approaching this problem.</p><p>It is possible to overlay a mask (a second image with a transparent centre) in an overlaid div, but this solution has one big drawback: Internet Explorer has patchy support for the only image format which has full alpha support, png24. Which means you are stuck with using a gif, and with jagged edges.</p><p>A much better way is to get ImageMagick, one of the graphics processors included with EzPublish, to do the work. It is theoretically possible to get ImageMagick to measure the picture and draw the mask, but this is complicated (if anyone gets it to work please let us know). These discussions may be a good starting place if you feel like taking this to the next level:</p><p><a href="https://www.imagemagick.org/Usage/thumbnails/#rounded_border" title="https://www.imagemagick.org/Usage/thumbnails/#rounded_border" target="_self">https://www.imagemagick.org/Usage/thumbnails/#rounded_border</a></p><p>This section of the ImageMagick useage manual gives details on this, but there are hurdles which would need to be overcome, such as getting ImageMagick in EzPublish to read external vector files (.mvg) and some more discussion here.</p><p><a href="https://www.imagemagick.org/discourse-server/viewtopic.php?f=1&amp;t=8401" title="https://www.imagemagick.org/discourse-server/viewtopic.php?f=1&amp;t=8401" target="_self">https://www.imagemagick.org/discourse-server/viewtopic.php?f=1&amp;t=8401</a></p><p>For my particular use case we needed the resulting images to conform to an exact size, so rather than tackling the really hard stuff I elected to get ImageMagick to pull a png24 matt image from the design directory and overlay it on the source image. This is a simpler version of the technique described here:</p><p> <a href="https://www-128.ibm.com/developerworks/library/l-graf2/?ca=dgr-lnxw15GraphicsLine" title="https://www-128.ibm.com/developerworks/library/l-graf2/?ca=dgr-lnxw15GraphicsLine" target="_self">https://www-128.ibm.com/developerw...y/l-graf2/?ca=dgr-lnxw15GraphicsLine</a> <br />&nbsp;but as the final image size is pre-determined there is no need to add the corners individually.</p><a name="eztoc160429_3" id="eztoc160429_3"></a><h2>Directions</h2><p>This is what you need to do</p><a name="eztoc160429_3_1" id="eztoc160429_3_1"></a><h3>Dependencies</h3><p>The first thing you'll need to do is to establish whether the version of ImageMagick supports the -composite command. In the case of our host, Atvert Systems, we discovered that they were running the default version which shipped with the operating system - 6.0.7.1-16. (and this situation is quite likely for a professional hosting environment where system stability is more of a priority than having the latest versions of all components)</p><p>Luckily Karl, who runs Atvert, was very helpful in identifying the problem and he quickly upgraded ImageMagick to version 6.3.2.7-1, which supports the necessary commands.</p><a name="eztoc160429_3_2" id="eztoc160429_3_2"></a><h3>Images</h3><p>The next step is to make a test graphic, you can skip this if you are feeling really sure of yourself but I'd recommend it - you'll probably save yourself a few headaches. Make a two layer Photoshop (but make sure you convert the background layer to an normal one in PS's case) or Gimp file, put the word 'front' on one layer and the work 'back' on another, both with transparent backgrounds. Export the two layers as png24s with transparency. Put the 'front' one in your siteaccess images folder - that will eventually be your matt.</p><p>You now need to find out the 'fully qualified path' to that folder. It won't be the ftp path. In our case in involved prepending /var/www/html/ to the address you see in an ftp client. It's probably best to contact your hosting provider on this, unless you feel like a lot of guessing.</p><a name="eztoc160429_3_3" id="eztoc160429_3_3"></a><h3>Settings</h3><p>Next, open image.ini.append.php. you can do this in either the siteaccess copy or the override copy. Just don't do it in both ! :)</p><p> The first thing to add is the filter definition, it goes in the [ImageMagick]<br /> &nbsp;section:<br />&nbsp;</p> <pre class="xml" style="font-family:monospace;">[ImageMagick] Filters[]=rounded=-compose dst-over -composite -gravity NorthWest /var/www/html/ ... more path goes here ... /design/news_site/images/picmask.png</pre><p> &nbsp;<br /> This makes a filter called 'rounded', makes the destination go over the source, references the overlay to the top left corner and calls the matt image<br /> The -gravity switch may not be necessary. <br /> Next, make an alias for the image which will use the filter:<br />&nbsp;</p> <pre class="xml" style="font-family:monospace;">[AliasSettings] AliasList[]=mypicturewitharoundedborder</pre><p>Finally, add the filters to the alias;</p> <pre class="xml" style="font-family:monospace;">[mypicturewitharoundedborder] Filters[]=geometry/scalewidth=156 Filters[]=geometry/crop=156;90;0;0 Filters[]=rounded=</pre><p> &nbsp;<br />The final filter applies the mask.</p><p>Save and upload the ini file, go to your EzPublish Online Editor, choose an image (the 'back' one you made earlier) choose the mypicturewitharoundedborder alias from the dropdown and publish. When you are happy that it's working delete the 'front' image and replace it with one that does something useful!</p><a name="eztoc160429_3_4" id="eztoc160429_3_4"></a><h3>Additional example:</h3><p>A fully detailed implementation: <a href="https://www.mugo.ca/Blog/Applying-borders-to-eZ-Publish-images-using-ImageMagick" title="Applying borders to eZ Publish images using ImageMagick" target="_self">Applying borders to eZ Publish images using ImageMagick</a></p><a name="eztoc160429_4" id="eztoc160429_4"></a><h2>Special Thanks</h2><p>Thanks to Bruce Morrison from DesignIT for his invaluable help in wrangling ImageMagick's sometimes slightly-less-than-intuitive command line syntax.</p> Fri, 03 May 2013 18:00:27 GMT Template Variable Scope / Passing Variables to Template https://ezpedia.org/snippet/template_variable_scope_passing_variables_to_template https://ezpedia.org/snippet/template_variable_scope_passing_variables_to_template <a name="eztoc3575_1" id="eztoc3575_1"></a><h2>Question</h2><p>Is there anything like <i>$module_result.content_info.persistent_variable</i></p><p>I could use instead of it? Something to pass data from tpl of shop to <i>pagelayout.tpl</i></p><a name="eztoc3575_2" id="eztoc3575_2"></a><h2>Solution</h2><p>Found out I can use <i>{set-block scope=global variable=NAME}VALUE{/set-block}</i></p><p>References</p> <ul> <li>Doc:&nbsp;<a href="/es/ez/persistent_template_variables" target="_self">Persistent template variables</a></li> </ul> Sun, 15 Jan 2012 20:38:22 GMT Template logic to perform search and replace on strings https://ezpedia.org/snippet/template_logic_to_perform_search_and_replace_on_strings https://ezpedia.org/snippet/template_logic_to_perform_search_and_replace_on_strings <p>Hello, in this post I will show how to perform a simple string search and replace within an eZ Publish template variable.</p><p>Many new users to eZ Publish incorrectly think there is no search and replace operator within the eZ Publish template language...</p><p>Consider the following examples. I find them to be simpler and faster to use together than to mess with yet another custom operator or wrap_operator function call.</p><p>First you can do this in any template. Here is an example. Put this code into a template file:</p> <pre class="eztemplate" style="font-family:monospace;"><span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=def&SearchContentClassID=34"><span style="color: #0600FF;">def</span></a> <span style="color: #0000bb;">$strDataInput</span><span style="color: #66cc66;">=</span><span style="color: #dd0000;">'09/17/2011'</span> <span style="color: #0000bb;">$strData</span><span style="color: #66cc66;">=</span><span style="color: #0000bb;">$strDataInput</span><span style="color: #66cc66;">|</span>explode<span style="color: #66cc66;">&#40;</span><span style="color: #dd0000;">'/'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span>implode<span style="color: #66cc66;">&#40;</span><span style="color: #dd0000;">'.'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span> &nbsp; <span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$strData</span><span style="color: #66cc66;">&#125;</span><span style="color: #808080; font-style: italic;">{* $strData will output '09.17.2011' *}</span> &nbsp; <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=undef&SearchContentClassID=34"><span style="color: #0600FF;">undef</span></a><span style="color: #66cc66;">&#125;</span>&amp;nbsp; &nbsp;</pre><p>This also works the same way in php. Here is an example:</p> <pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #000088;">$input</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'abcd efg hijk lmnop qrs tuv wxyz'</span><span style="color: #339933;">;</span> <span style="color: #000088;">$output</span> <span style="color: #339933;">=</span> <a href="https://www.php.net/implode"><span style="color: #990000;">implode</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'-'</span><span style="color: #339933;">,</span> <a href="https://www.php.net/explode"><span style="color: #990000;">explode</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">' '</span><span style="color: #339933;">,</span> <span style="color: #000088;">$input</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <a href="https://www.php.net/print_r"><span style="color: #990000;">print_r</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$input</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <a href="https://www.php.net/print_r"><span style="color: #990000;">print_r</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$output</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre><p>I hope this helps others looking to avoid extra dependencies and complexities without giving up much needed functionality :)</p><p> <a name='eztoc559948_0_0_1'></a></p><a name="eztoc699260_0_0_0_1" id="eztoc699260_0_0_0_1"></a><h5>References</h5><p>[0]&nbsp;<a href="https://doc.ez.no/eZ-Publish/Technical-manual/3.9/Reference/Template-operators/Strings/str_replace/(language)/eng-GB" target="_self">https://doc.ez.no/eZ-Publish/Technical-manual/3.9/Reference/Template-operators/Strings/str_replace/(language)/eng-GB</a></p><p>[1]&nbsp;<a href="https://doc.ez.no/eZ-Publish/Technical-manual/4.x/Reference/Template-operators/Arrays/implode/Convert-spaces-in-text-to-dashes/(language)/eng-GB" target="_self">https://doc.ez.no/eZ-Publish/Technical-manual/4.x/Reference/Template-operators/Arrays/implode/Convert-spaces-in-text-to-dashes/(language)/eng-GB</a></p><p>[2]&nbsp;<a href="https://doc.ez.no/eZ-Publish/Technical-manual/4.x/Reference/Template-operators/replacement-operator/Re-replacement-operator/(language)/eng-GB" target="_self">https://doc.ez.no/eZ-Publish/Technical-manual/4.x/Reference/Template-operators/replacement-operator/Re-replacement-operator/(language)/eng-GB</a></p><p>[3]&nbsp;<a href="https://doc.ez.no/eZ-Publish/Technical-manual/4.x/Reference/Template-operators/Strings/explode/Explode-Implode-as-string-replacement/(language)/eng-GB" target="_self">https://doc.ez.no/eZ-Publish/Technical-manual/4.x/Reference/Template-operators/Strings/explode/Explode-Implode-as-string-replacement/(language)/eng-GB</a></p><p>[4]&nbsp;<a href="https://doc.ez.no/eZ-Publish/Technical-manual/4.x/Reference/Template-operators/Arrays/implode/(language)/eng-GB" target="_self">https://doc.ez.no/eZ-Publish/Technical-manual/4.x/Reference/Template-operators/Arrays/implode/(language)/eng-GB</a></p><p>[5]&nbsp;<a href="https://doc.ez.no/eZ-Publish/Technical-manual/4.x/Reference/Template-operators/Strings/explode" target="_self">https://doc.ez.no/eZ-Publish/Technical-manual/4.x/Reference/Template-operators/Strings/explode</a></p><p>[6]&nbsp;<a href="https://share.ez.no/blogs/brookins-consulting/tip-ez-publish-template-variable-search-and-replace" target="_self">https://share.ez.no/blogs/brookins-consulting/tip-ez-publish-template-variable-search-and-replace</a></p> Sun, 18 Sep 2011 05:37:17 GMT PHP Snippet Creating new content objects https://ezpedia.org/snippet/php_snippet_creating_new_content_objects https://ezpedia.org/snippet/php_snippet_creating_new_content_objects <a name="eztoc400_1" id="eztoc400_1"></a><h2>Compatibility</h2> <div class="object-center"> <p class="version_info">This feature is available since <a href="/es/ez/ez_publish_3_9" target="_self">eZ publish 3.9</a>.</p></div><p>From eZ Publish 3.9 on, there's also the static method eZContentFunctions::createAndPublishObject() which handles object creation, filling attributes and publishing at one location. The filling of the attributes is handled by the fromString functions implemented by the datatypes. For more information on this, see the <a href="/es/ez/simple_fromstring_and_tostring_interface_for_attributes" target="_self">fromString and toString feature doc</a>.</p><a name="eztoc400_2" id="eztoc400_2"></a><h2>Permission checking</h2><p>If you want to bypass the policy system, then remove the conditional check on $accessResult</p><a name="eztoc400_3" id="eztoc400_3"></a><h2>Code sample</h2><p>The following code will create a new content object and an initial draft version. It is based on a part of the action view of the content module (kernel/content/action.php).</p><a name="eztoc400_3_1" id="eztoc400_3_1"></a><h3>The known variables</h3> <ul> <li>$contentClassIdentifier: identifier of the content class we want to make an object of</li> <li>$node: the parent node for the new object's main location in the node tree</li> </ul> <pre class="php" style="font-family:monospace;"><span style="color: #000088;">$class</span> <span style="color: #339933;">=</span> eZContentClass<span style="color: #339933;">::</span><span style="color: #004000;">fetchByIdentifier</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$contentClassIdentifier</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <a href="https://www.php.net/is_object"><span style="color: #990000;">is_object</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$class</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$contentClassID</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$class</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'id'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$parentContentObject</span> <span style="color: #339933;">=&amp;</span> <span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'object'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$accessResult</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$parentContentObject</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">checkAccess</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'create'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$contentClassID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$parentContentObject</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'contentclass_id'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$accessResult</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'1'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'kernel/classes/datatypes/ezuser/ezuser.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$user</span> <span style="color: #339933;">=&amp;</span> eZUser<span style="color: #339933;">::</span><span style="color: #004000;">currentUser</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$userID</span> <span style="color: #339933;">=&amp;</span> <span style="color: #000088;">$user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'contentobject_id'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$sectionID</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$parentContentObject</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'section_id'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'lib/ezdb/classes/ezdb.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$db</span> <span style="color: #339933;">=&amp;</span> eZDB<span style="color: #339933;">::</span><span style="color: #004000;">instance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">begin</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$contentObject</span> <span style="color: #339933;">=&amp;</span> <span style="color: #000088;">$class</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">instantiate</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$userID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$sectionID</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$nodeAssignment</span> <span style="color: #339933;">=</span> eZNodeAssignment<span style="color: #339933;">::</span><span style="color: #004000;">create</span><span style="color: #009900;">&#40;</span> <a href="https://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'contentobject_id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$contentObject</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'id'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'contentobject_version'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$contentObject</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'current_version'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'parent_node'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'node_id'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'is_main'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$nodeAssignment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">store</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">commit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span></pre><p>Now that you have created a new content object, you will probably want to fill it's attributes with data and publish it.</p> Fri, 29 Jan 2010 18:34:49 GMT Creating new content objects with php https://ezpedia.org/snippets_for_ez_publish_3/creating_new_content_objects_with_php https://ezpedia.org/snippets_for_ez_publish_3/creating_new_content_objects_with_php <a name="eztoc383448_1" id="eztoc383448_1"></a><h2>Compatibility</h2> <div class="object-center"> <p class="version_info">This feature is available since <a href="/es/ez/ez_publish_3_9" target="_self">eZ publish 3.9</a>.</p></div><p>From eZ Publish 3.9 on, there's also the static method eZContentFunctions::createAndPublishObject() which handles object creation, filling attributes and publishing at one location. The filling of the attributes is handled by the fromString functions implemented by the datatypes. For more information on this, see the <a href="/es/ez/simple_fromstring_and_tostring_interface_for_attributes" target="_self">fromString and toString feature doc</a>.</p><a name="eztoc383448_2" id="eztoc383448_2"></a><h2>Permission checking</h2><p>If you want to bypass the policy system, then remove the conditional check on $accessResult</p><a name="eztoc383448_3" id="eztoc383448_3"></a><h2>Code sample</h2><p>The following code will create a new content object and an initial draft version. It is based on a part of the action view of the content module (kernel/content/action.php).</p><a name="eztoc383448_3_1" id="eztoc383448_3_1"></a><h3>The known variables</h3> <ul> <li>$contentClassIdentifier: identifier of the content class we want to make an object of</li> <li>$node: the parent node for the new object's main location in the node tree</li> </ul> <pre class="php" style="font-family:monospace;"><span style="color: #000088;">$class</span> <span style="color: #339933;">=</span> eZContentClass<span style="color: #339933;">::</span><span style="color: #004000;">fetchByIdentifier</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$contentClassIdentifier</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <a href="https://www.php.net/is_object"><span style="color: #990000;">is_object</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$class</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$contentClassID</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$class</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'id'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$parentContentObject</span> <span style="color: #339933;">=&amp;</span> <span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'object'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$accessResult</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$parentContentObject</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">checkAccess</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'create'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$contentClassID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$parentContentObject</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'contentclass_id'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$accessResult</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'1'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'kernel/classes/datatypes/ezuser/ezuser.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$user</span> <span style="color: #339933;">=&amp;</span> eZUser<span style="color: #339933;">::</span><span style="color: #004000;">currentUser</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$userID</span> <span style="color: #339933;">=&amp;</span> <span style="color: #000088;">$user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'contentobject_id'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$sectionID</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$parentContentObject</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'section_id'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'lib/ezdb/classes/ezdb.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$db</span> <span style="color: #339933;">=&amp;</span> eZDB<span style="color: #339933;">::</span><span style="color: #004000;">instance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">begin</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$contentObject</span> <span style="color: #339933;">=&amp;</span> <span style="color: #000088;">$class</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">instantiate</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$userID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$sectionID</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$nodeAssignment</span> <span style="color: #339933;">=</span> eZNodeAssignment<span style="color: #339933;">::</span><span style="color: #004000;">create</span><span style="color: #009900;">&#40;</span> <a href="https://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'contentobject_id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$contentObject</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'id'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'contentobject_version'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$contentObject</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'current_version'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'parent_node'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'node_id'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'is_main'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$nodeAssignment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">store</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">commit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span></pre><p>Now that you have created a new content object, you will probably want to fill it's attributes with data and publish it.</p> Fri, 29 Jan 2010 18:33:32 GMT PHP Snippet Hiding or unhiding subtrees https://ezpedia.org/snippet/php_snippet_hiding_or_unhiding_subtrees https://ezpedia.org/snippet/php_snippet_hiding_or_unhiding_subtrees <div class="object-right"><p class="version_info">This is compatible with <a href="/es/ez/ez_publish_4" target="_self">eZ Publish 4</a>.</p></div><a name="eztoc306943_1" id="eztoc306943_1"></a><h2>About</h2><p>eZ Publish content object tree node <a href="https://ez.no/doc/ez_publish/technical_manual/4_0/concepts_and_basics/content_management/node_visibility" target="_self">visibility</a> can be changed.</p><a name="eztoc306943_2" id="eztoc306943_2"></a><h2>Example code</h2> <pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'can_hide'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'is_hidden'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> eZContentObjectTreeNode<span style="color: #339933;">::</span><span style="color: #004000;">unhideSubTree</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$node</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span> eZContentObjectTreeNode<span style="color: #339933;">::</span><span style="color: #004000;">hideSubTree</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$node</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span></pre><a name="eztoc306943_3" id="eztoc306943_3"></a><h2>References</h2> <ul> <li>Doc: <a href="https://ez.no/doc/ez_publish/technical_manual/4_0/concepts_and_basics/content_management/node_visibility" target="_self">node visibility</a></li> </ul> Tue, 18 Aug 2009 10:56:21 GMT PHP eZ Publish API Source code examples https://ezpedia.org/snippet/php_ez_publish_api_source_code_examples https://ezpedia.org/snippet/php_ez_publish_api_source_code_examples <div class="object-center"> <p class="editor_motivation">This is a <a href="/es/template/stub">Stub</a> article. Help the eZ Publish community by expanding it!</p></div><p> This page will give you an overview of code samples which demonstrate how to use the eZ publish <a href="https://en.wikipedia.org/wiki/Application_programming_interface" target="_self">API</a>.</p><a name="eztoc388_1" id="eztoc388_1"></a><h2>Documentation</h2><p>The eZ Publish PHP API has been documented a number of ways. A popular reference presently is the <a href="/es/ez/doxygen" target="_self">doxygen</a> generated html documentation <a href="/es/learning/ez_publish_php_doxygen_api_documentation" target="_self">hosted</a> on <a href="https://pubsvn.ez.no" target="_blank">pubsvn.ez.no</a>.</p><a name="eztoc388_2" id="eztoc388_2"></a><h2>Content</h2><p>PHP examples related to interactions related to database content access and manipulation.</p><a name="eztoc388_2_1" id="eztoc388_2_1"></a><h3>Objects and the node tree</h3><a name="eztoc388_2_1_1" id="eztoc388_2_1_1"></a><h4>Fetching data</h4> <ul> <li><a href="/es/snippet/php_snippet_clearning_in_memory_object_cache" target="_self">avoiding memory exhaustion</a></li> <li><a href="/es/snippet/template_logic_to_display_fetched_parent_content_object_name" target="_self">display fetched parent name</a></li> <li><a href="https://ez.no/community/forum/developer/how_to_do_a_fetch_with_php" target="_self">how to do a fetch with php</a></li> <li><a href="https://ez.no/community/forum/developer/how_to_update_an_attribute_of_an_object_with_php" target="_self">how to update an attribute of an object with php</a></li> <li><a href="https://ez.no/community/forum/developer/get_the_image_storage_path_from_a_contentobjectid_php_side" target="_self">get the image storage path from a ContentObjectID</a></li> <li><a href="https://ez.no/community/forum/general/fetching_user_data" target="_self">fetching user data</a></li> <li><a href="https://ez.no/community/forum/developer/how_to_fetch_class_objects_in_php" target="_self">how to fetch class objects in php</a></li> </ul> <p>&nbsp;</p><a name="eztoc388_2_1_2" id="eztoc388_2_1_2"></a><h4>Manipulating data </h4> <ul> <li><a href="/es/snippet/php_snippet_creating_new_content_objects" target="_self">creating new objects</a></li> <li> putting data into attributes</li> <li> adding relations</li> <li> placing objects in the node tree</li> <li><a href="/es/snippet/php_snippet_adding_additional_locations_for_an_object" target="_self">placing objects at additional locations</a></li> <li> updating objects = <a href="/es/snippet/php_snippet_creating_new_content_object_versions" target="_self">creating new content object versions</a> </li> <li> removing objects</li> <li><a href="/es/snippet/php_snippet_moving_a_node" target="_self">moving nodes</a></li> <li><a href="/es/snippet/php_snippet_hiding_or_unhiding_subtrees" target="_self">hiding and unhiding subtrees</a></li> <li><a href="/es/snippet/php_snippet_copying_objects" target="_self">copying objects</a></li> <li><a href="/es/snippet/php_snippet_assigning_sections" target="_self">assigning sections</a></li> <li> changing object ownership</li> </ul> <p>&nbsp;</p><a name="eztoc388_2_2" id="eztoc388_2_2"></a><h3>Classes</h3> <ul> <li> adding class attributes</li> <li> reordering class attributes</li> </ul> <p>&nbsp;</p><a name="eztoc388_2_3" id="eztoc388_2_3"></a><h3>Charsets</h3> <ul> <li> converting external data to the internal charset</li> </ul> <p>&nbsp;</p><a name="eztoc388_2_4" id="eztoc388_2_4"></a><h3>Notifications</h3> <ul> <li><a href="/es/snippet/php_snippet_adding_subtree_notification_rules" target="_self">adding subtree notification rules</a></li> <li> removing subtree notification rules</li> <li><a href="/es/snippet/php_snippet_adding_collaboration_notification_rules" target="_self">adding collaboration notifications rules</a></li> <li> removing collaboration notification rules</li> </ul> <p>&nbsp;</p><a name="eztoc388_3" id="eztoc388_3"></a><h2>Users</h2><a name="eztoc388_3_5" id="eztoc388_3_5"></a><h3>Authentication</h3> <ul> <li><a href="/es/snippet/php_snippet_logging_in_a_specific_user" target="_self">logging in a specific user</a></li> <li><a href="/es/solution/how_to_provide_for_intranet_ip_based_authentication" target="_self">ip based authentication</a></li> <li> authenticate with login handlers</li> </ul> <p>&nbsp;</p><a name="eztoc388_3_6" id="eztoc388_3_6"></a><h3>Roles</h3> <ul> <li><a href="/es/snippet/php_snippet_assigning_roles" target="_self">assigning roles</a></li> </ul> <p>&nbsp;</p><a name="eztoc388_3_7" id="eztoc388_3_7"></a><h3>Preferences</h3> <ul> <li> setting user preferences</li> <li> removing user preferences</li> </ul> Tue, 18 Aug 2009 05:05:35 GMT Template logic to find object by node_id or object_id https://ezpedia.org/snippet/template_logic_to_find_object_by_node_id_or_object_id https://ezpedia.org/snippet/template_logic_to_find_object_by_node_id_or_object_id <a name="eztoc40025_1" id="eztoc40025_1"></a><h2>Question</h2><p>How can you 'find' an object, if all that is known is the node_id?</p><a name="eztoc40025_2" id="eztoc40025_2"></a><h2>Answer</h2> <pre class="eztemplate" style="font-family:monospace;"><span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=def&SearchContentClassID=34"><span style="color: #0600FF;">def</span></a> <span style="color: #0000bb;">$my_node</span><span style="color: #66cc66;">=</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=fetch&SearchContentClassID=31"><span style="color: #0600FF;">fetch</span></a><span style="color: #66cc66;">&#40;</span> <span style="color: #dd0000;">'content'</span>, <span style="color: #dd0000;">'node'</span>, <a href="https://ez.no/doc/content/advancedsearch?SearchText=hash&SearchContentClassID=31"><span style="color: #0600FF;">hash</span></a><span style="color: #66cc66;">&#40;</span> <span style="color: #dd0000;">'node_id'</span>, <span style="color: #0000bb;">$node</span>.<span style="color: #006600;">node_id</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #0000bb;">$my_object</span><span style="color: #66cc66;">=</span><span style="color: #0000bb;">$my_node</span>.<span style="color: #006600;">object</span><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$my_node</span>.<span style="color: #006600;">name</span><span style="color: #66cc66;">|</span>wash<span style="color: #66cc66;">&#125;</span></pre><a name="eztoc40025_3" id="eztoc40025_3"></a><h2>External reference</h2> <ul> <li>Forum: <a href="https://ez.no/community/forum/general/howto_find_object_by_node_id" target="_self">How to find object by node_id</a>?</li> <li><i><a href="https://ez.no/doc/ez_publish/technical_manual/3_8/reference/modules/content/fetch_functions/node" title="https://ez.no/doc/ez_publish/technical_manual/3_8/reference/modules/content/fetch_functions/node" target="_self">https://ez.no/doc/ez_publish/techn...modules/content/fetch_functions/node</a></i></li> <li><i><a href="https://ez.no/doc/ez_publish/technical_manual/3_8/reference/modules/content/fetch_functions/list" title="https://ez.no/doc/ez_publish/technical_manual/3_8/reference/modules/content/fetch_functions/list" target="_self">https://ez.no/doc/ez_publish/techn...modules/content/fetch_functions/list</a></i></li> </ul> Tue, 18 Aug 2009 04:17:46 GMT Template logic to fetch using an attribute filter using the like condition https://ezpedia.org/snippet/template_logic_to_fetch_using_an_attribute_filter_using_the_like_condition https://ezpedia.org/snippet/template_logic_to_fetch_using_an_attribute_filter_using_the_like_condition <p>We have seen this question asked many times and wanted to ensure this question is simpler to answer in the future</p><a name="eztoc205146_1" id="eztoc205146_1"></a><h2>Question</h2><p>How <i>exactly</i> do you use an attribute filter using the like condition?</p><a name="eztoc205146_2" id="eztoc205146_2"></a><h2>Solutions</h2><p>These solutions have been tested but may not be generic, so some modifications to ids etc may be required.</p><a name="eztoc205146_2_1" id="eztoc205146_2_1"></a><h3>Filter by Class/Attribute Identifier</h3> <pre class="eztemplate" style="font-family:monospace;"><span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=def&SearchContentClassID=34"><span style="color: #0600FF;">def</span></a> <span style="color: #0000bb;">$c</span><span style="color: #66cc66;">=</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=fetch&SearchContentClassID=31"><span style="color: #0600FF;">fetch</span></a><span style="color: #66cc66;">&#40;</span> <span style="color: #dd0000;">'content'</span>, <span style="color: #dd0000;">'tree'</span>, <a href="https://ez.no/doc/content/advancedsearch?SearchText=hash&SearchContentClassID=31"><span style="color: #0600FF;">hash</span></a><span style="color: #66cc66;">&#40;</span> <span style="color: #dd0000;">'parent_node_id'</span>, <span style="color: #cc66cc;">175</span>, depth, <span style="color: #cc66cc;">7</span>, attribute_filter, <a href="https://ez.no/doc/content/advancedsearch?SearchText=array&SearchContentClassID=31"><span style="color: #0600FF;">array</span></a><span style="color: #66cc66;">&#40;</span> <a href="https://ez.no/doc/content/advancedsearch?SearchText=array&SearchContentClassID=31"><span style="color: #0600FF;">array</span></a><span style="color: #66cc66;">&#40;</span> <span style="color: #dd0000;">'article/keywords'</span>, <span style="color: #dd0000;">'like'</span>, <span style="color: #dd0000;">'*string*'</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span> &nbsp; <span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$c</span><span style="color: #66cc66;">|</span>attribute<span style="color: #66cc66;">&#40;</span>show,<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$c</span>.0<span style="color: #66cc66;">|</span>attribute<span style="color: #66cc66;">&#40;</span>show,<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span> &nbsp;</pre><a name="eztoc205146_2_2" id="eztoc205146_2_2"></a><h3>Filter by Attribute ID</h3> <pre class="eztemplate" style="font-family:monospace;"><span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=def&SearchContentClassID=34"><span style="color: #0600FF;">def</span></a> <span style="color: #0000bb;">$c</span><span style="color: #66cc66;">=</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=fetch&SearchContentClassID=31"><span style="color: #0600FF;">fetch</span></a><span style="color: #66cc66;">&#40;</span> <span style="color: #dd0000;">'content'</span>, <span style="color: #dd0000;">'tree'</span>, <a href="https://ez.no/doc/content/advancedsearch?SearchText=hash&SearchContentClassID=31"><span style="color: #0600FF;">hash</span></a><span style="color: #66cc66;">&#40;</span> <span style="color: #dd0000;">'parent_node_id'</span>, <span style="color: #cc66cc;">175</span>, depth, <span style="color: #cc66cc;">7</span>, attribute_filter, <a href="https://ez.no/doc/content/advancedsearch?SearchText=array&SearchContentClassID=31"><span style="color: #0600FF;">array</span></a><span style="color: #66cc66;">&#40;</span> <a href="https://ez.no/doc/content/advancedsearch?SearchText=array&SearchContentClassID=31"><span style="color: #0600FF;">array</span></a><span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">865</span>, <span style="color: #dd0000;">'like'</span>, <span style="color: #dd0000;">'*string*'</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span> &nbsp;</pre><a name="eztoc205146_2_3" id="eztoc205146_2_3"></a><h3>Filter by dynamic string variable</h3> <pre class="eztemplate" style="font-family:monospace;"><span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=def&SearchContentClassID=34"><span style="color: #0600FF;">def</span></a> <span style="color: #0000bb;">$tag</span><span style="color: #66cc66;">=</span><span style="color: #dd0000;">'string'</span><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=def&SearchContentClassID=34"><span style="color: #0600FF;">def</span></a> <span style="color: #0000bb;">$c</span><span style="color: #66cc66;">=</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=fetch&SearchContentClassID=31"><span style="color: #0600FF;">fetch</span></a><span style="color: #66cc66;">&#40;</span> <span style="color: #dd0000;">'content'</span>, <span style="color: #dd0000;">'tree'</span>, <a href="https://ez.no/doc/content/advancedsearch?SearchText=hash&SearchContentClassID=31"><span style="color: #0600FF;">hash</span></a><span style="color: #66cc66;">&#40;</span> <span style="color: #dd0000;">'parent_node_id'</span>, <span style="color: #cc66cc;">175</span>, depth, <span style="color: #cc66cc;">7</span>, attribute_filter, <a href="https://ez.no/doc/content/advancedsearch?SearchText=array&SearchContentClassID=31"><span style="color: #0600FF;">array</span></a><span style="color: #66cc66;">&#40;</span> <a href="https://ez.no/doc/content/advancedsearch?SearchText=array&SearchContentClassID=31"><span style="color: #0600FF;">array</span></a><span style="color: #66cc66;">&#40;</span> <span style="color: #dd0000;">'article/keywords'</span>, <span style="color: #dd0000;">'like'</span>, <a href="https://ez.no/doc/content/advancedsearch?SearchText=concat&SearchContentClassID=31"><span style="color: #0600FF;">concat</span></a><span style="color: #66cc66;">&#40;</span> <span style="color: #dd0000;">'*'</span>, <span style="color: #0000bb;">$tag</span>, <span style="color: #dd0000;">'*'</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span> &nbsp;</pre><a name="eztoc205146_2_4" id="eztoc205146_2_4"></a><h3>Warning</h3><p>Be certain to clear <a href="/es/ez/cache" target="_self">cache</a> or <a href="/es/solution/template_development_without_clearing_cache" target="_self">disable cache</a>!</p><a name="eztoc205146_3" id="eztoc205146_3"></a><h2>References</h2> <ul> <li>Forum: <a href="https://ez.no/community/forum/developer/attribute_filter_breaking_fetch#msg144793" target="_self">How to use an attribute filter like condition?</a> </li> <li>Doc: <a href="https://ez.no/doc/ez_publish/technical_manual/3_9/reference/modules/content/fetch_functions/list#eztoc64252_0_0_1" target="_self">Reference, fetch functions, list</a> </li> </ul> Tue, 18 Aug 2009 02:21:51 GMT Template logic to dynamically generate css stylesheets https://ezpedia.org/snippet/template_logic_to_dynamically_generate_css_stylesheets https://ezpedia.org/snippet/template_logic_to_dynamically_generate_css_stylesheets <div class="object-center"> <p class="editor_motivation">This is a <a href="/es/template/stub">Stub</a> article. Help the eZ Publish community by expanding it!</p></div><a name="eztoc575_1" id="eztoc575_1"></a><h2>About</h2><p>Template logic for dynamically generating css stylesheets</p><a name="eztoc575_2" id="eztoc575_2"></a><h2>Solutions</h2><p>...</p><a name="eztoc575_3" id="eztoc575_3"></a><h2>Reference</h2> <ul> <li>Forum: <a href="https://ez.no/community/forum/setup_design/generating_css_dynamically_setting_a_content_type#msg71167" title="https://ez.no/community/forum/setup_design/generating_css_dynamically_setting_a_content_type#msg71167" target="_blank">Generating CSS Dynamically...</a></li> </ul> Tue, 18 Aug 2009 02:18:01 GMT Template logic to display content object tree node locations https://ezpedia.org/snippet/template_logic_to_display_content_object_tree_node_locations https://ezpedia.org/snippet/template_logic_to_display_content_object_tree_node_locations <div class="object-center"> <p class="editor_motivation">This is a <a href="/es/template/stub">Stub</a> article. Help the eZ Publish community by expanding it!</p></div><a name="eztoc18285_1" id="eztoc18285_1"></a><h2>Question</h2><p><i>'Is there any attribute or other way to find out, if an object has more than one locations?' </i></p><a name="eztoc18285_2" id="eztoc18285_2"></a><h2>Solution</h2><p>The assigned nodes is available on the object. </p><p>Here is an example code that lists all the paths to the assigned nodes:</p> <pre class="eztemplate" style="font-family:monospace;"><span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=foreach&SearchContentClassID=23"><span style="color: #0600FF;">foreach</span></a> <span style="color: #0000bb;">$node</span>.<span style="color: #006600;">object</span>.<span style="color: #006600;">assigned_nodes</span> as <span style="color: #0000bb;">$assignednode</span><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$assignednode</span>.<span style="color: #006600;">path_identification_string</span><span style="color: #66cc66;">&#125;</span> &lt;br /&gt; <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=foreach&SearchContentClassID=23"><span style="color: #0600FF;">foreach</span></a><span style="color: #66cc66;">&#125;</span>&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;&lt;/pre&gt;</pre><p> The $node variable has the following available information:<br /> <a href="https://ez.no/doc/ez_publish/technical_manual/3_8/reference/objects/ezcontentobjecttreenode" title="https://ez.no/doc/ez_publish/technical_manual/3_8/reference/objects/ezcontentobjecttreenode" target="_self">https://ez.no/doc/ez_publish/techn...ence/objects/ezcontentobjecttreenode</a><br /> The $node.object:<br /><a href="https://ez.no/doc/ez_publish/technical_manual/3_8/reference/objects/ezcontentobject" title="https://ez.no/doc/ez_publish/technical_manual/3_8/reference/objects/ezcontentobject" target="_self">https://ez.no/doc/ez_publish/techn..._8/reference/objects/ezcontentobject</a></p><a name="eztoc18285_2_1" id="eztoc18285_2_1"></a><h3>Another Solution</h3><p> Actually. In your case, you might be able to use the &quot;main_node_only&quot; parameter to the &quot;list&quot; or &quot;tree&quot; fetch to only return the main node of your nodes.<br /> See here:<br /><a href="https://ez.no/doc/ez_publish/technical_manual/3_8/reference/modules/content/fetch_functions/list" title="https://ez.no/doc/ez_publish/technical_manual/3_8/reference/modules/content/fetch_functions/list" target="_self">https://ez.no/doc/ez_publish/techn...modules/content/fetch_functions/list</a></p><p><i>Reply, &quot;The main_node_only attribute would not work with the particular problem logic I have: I wanted to exclude all &quot;Main Nodes&quot; from the fetch, whose objects are encapsulated by another node (different location).&quot;</i></p><a name="eztoc18285_3" id="eztoc18285_3"></a><h2>External References</h2> <ul> <li>Forum: <a href="https://ez.no/community/forum/setup_design/detecting_locations_of_a_node_is_there_any_attribute" target="_self">Detecting locations of a node</a> ...</li> </ul> Tue, 18 Aug 2009 02:16:44 GMT Template logic to display dynamic tertiary menu https://ezpedia.org/snippet/template_logic_to_display_dynamic_tertiary_menu https://ezpedia.org/snippet/template_logic_to_display_dynamic_tertiary_menu <p>Created by Graham Brookins | Brookins Consulting</p><a name="eztoc766_1" id="eztoc766_1"></a><h2>About</h2><p>Initial posting of this example .... </p><p>This was created for a client who wanted a menu system that was 3 levels deep, server-side collapsable, current menu/document selected style. All I will say is that it works, fairly well. There are some static exceptions with variables you can change or remove the exceptions entirely. </p><p>I will post a cleaned up version of the source code with beter comments and less commented out code.</p><a name="eztoc766_2" id="eztoc766_2"></a><h2>Template </h2> <pre class="eztemplate" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">{* ##################################################################################### *}</span> <span style="color: #808080; font-style: italic;">{* Level 1 : Top Level Node : Submenu List {* ##################################################################################### *}</span> &nbsp; <span style="color: #808080; font-style: italic;">{* Exclude specials_node_id , static exception *}</span> <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=set&SearchContentClassID=34"><span style="color: #0600FF;">set</span></a> <span style="color: #007700;">specials_node_id</span><span style="color: #66cc66;">=</span><span style="color: #cc66cc;">118</span><span style="color: #66cc66;">&#125;</span> &nbsp; <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=let&SearchContentClassID=34"><span style="color: #0600FF;">let</span></a> <span style="color: #007700;">submenu</span><span style="color: #66cc66;">=</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=fetch&SearchContentClassID=31"><span style="color: #0600FF;">fetch</span></a><span style="color: #66cc66;">&#40;</span> content, list, <a href="https://ez.no/doc/content/advancedsearch?SearchText=hash&SearchContentClassID=31"><span style="color: #0600FF;">hash</span></a><span style="color: #66cc66;">&#40;</span> parent_node_id, <span style="color: #0000bb;">$module_result</span>.<span style="color: #006600;">node_id</span>, sort_by,<a href="https://ez.no/doc/content/advancedsearch?SearchText=array&SearchContentClassID=31"><span style="color: #0600FF;">array</span></a><span style="color: #66cc66;">&#40;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=array&SearchContentClassID=31"><span style="color: #0600FF;">array</span></a><span style="color: #66cc66;">&#40;</span>priority, <a href="https://ez.no/doc/content/advancedsearch?SearchText=false&SearchContentClassID=31"><span style="color: #0600FF;">false</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #007700;">parent</span><span style="color: #66cc66;">=</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=fetch&SearchContentClassID=31"><span style="color: #0600FF;">fetch</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #dd0000;">'content'</span>,<span style="color: #dd0000;">'node'</span>, <a href="https://ez.no/doc/content/advancedsearch?SearchText=hash&SearchContentClassID=31"><span style="color: #0600FF;">hash</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #dd0000;">'node_id'</span>, <span style="color: #0000bb;">$module_result</span>.<span style="color: #006600;">node_id</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#125;</span> &nbsp; <span style="color: #808080; font-style: italic;">{* ##################################################################################### *}</span> &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">{* ##################################################################################### *}</span> <span style="color: #808080; font-style: italic;">{* Level 3+ : Reverse Submenu List (Which we are not using now) {* ##################################################################################### *}</span> <span style="color: #808080; font-style: italic;">{* These are good rules for reverse *}</span> <span style="color: #808080; font-style: italic;">{* {section show=and($DesignKeys:used.parent_node|ne(2), $submenu|count|lt(1))}</span> &nbsp; <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=set&SearchContentClassID=34"><span style="color: #0600FF;">set</span></a> <span style="color: #007700;">submenu</span><span style="color: #66cc66;">=</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=fetch&SearchContentClassID=31"><span style="color: #0600FF;">fetch</span></a><span style="color: #66cc66;">&#40;</span> content, list, <a href="https://ez.no/doc/content/advancedsearch?SearchText=hash&SearchContentClassID=31"><span style="color: #0600FF;">hash</span></a><span style="color: #66cc66;">&#40;</span> parent_node_id, <span style="color: #0000bb;">$DesignKeys:used</span>.<span style="color: #006600;">parent_node</span>, sort_by,<a href="https://ez.no/doc/content/advancedsearch?SearchText=array&SearchContentClassID=31"><span style="color: #0600FF;">array</span></a><span style="color: #66cc66;">&#40;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=array&SearchContentClassID=31"><span style="color: #0600FF;">array</span></a><span style="color: #66cc66;">&#40;</span>priority, <a href="https://ez.no/doc/content/advancedsearch?SearchText=false&SearchContentClassID=31"><span style="color: #0600FF;">false</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #007700;">parent</span><span style="color: #66cc66;">=</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=fetch&SearchContentClassID=31"><span style="color: #0600FF;">fetch</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #dd0000;">'content'</span>, <span style="color: #dd0000;">'node'</span>, <a href="https://ez.no/doc/content/advancedsearch?SearchText=hash&SearchContentClassID=31"><span style="color: #0600FF;">hash</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #dd0000;">'node_id'</span>, <span style="color: #0000bb;">$module_result</span>.<span style="color: #006600;">content_info</span>.<span style="color: #006600;">parent_node_id</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#125;</span> &nbsp; <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=section&SearchContentClassID=23"><span style="color: #0600FF;">section</span></a><span style="color: #66cc66;">&#125;</span> *} &nbsp; <span style="color: #808080; font-style: italic;">{* END: These are good rules for reverse *}</span> <span style="color: #808080; font-style: italic;">{* ##################################################################################### *}</span> &nbsp; &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">{* ##################################################################################### *}</span> <span style="color: #808080; font-style: italic;">{* Level 3+ : Toplevel Attached Reverse Submenu List (works) {* ##################################################################################### *}</span> &nbsp; <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=section&SearchContentClassID=23"><span style="color: #0600FF;">section</span></a> <span style="color: #007700;">show</span><span style="color: #66cc66;">=</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=and&SearchContentClassID=31"><span style="color: #0600FF;">and</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000bb;">$DesignKeys:used</span>.<span style="color: #006600;">parent_node</span><span style="color: #66cc66;">|</span>ne<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #0000bb;">$module_result</span>.<span style="color: #006600;">content_info</span>.<span style="color: #006600;">node_depth</span><span style="color: #66cc66;">|</span>gt<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span> &nbsp; <span style="color: #808080; font-style: italic;">{* Depth: {$module_result.content_info.node_depth}</span>&lt;br /&gt; Key: <span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$DesignKeys:used</span>.<span style="color: #006600;">parent_node</span><span style="color: #66cc66;">&#125;</span> *} &nbsp; <span style="color: #808080; font-style: italic;">{* must test each parent per depth or use other to only get top level parents | parent, is not enough, part of prob, *}</span> <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=set&SearchContentClassID=34"><span style="color: #0600FF;">set</span></a> <span style="color: #007700;">parent</span><span style="color: #66cc66;">=</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=fetch&SearchContentClassID=31"><span style="color: #0600FF;">fetch</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #dd0000;">'content'</span>, <span style="color: #dd0000;">'node'</span>, <a href="https://ez.no/doc/content/advancedsearch?SearchText=hash&SearchContentClassID=31"><span style="color: #0600FF;">hash</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #dd0000;">'node_id'</span>, <span style="color: #0000bb;">$module_result</span>.<span style="color: #006600;">content_info</span>.<span style="color: #006600;">parent_node_id</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#125;</span> &nbsp; <span style="color: #808080; font-style: italic;">{* same as parent, need testing to only get top level: {set submenu=fetch( content, list, hash( parent_node_id, $DesignKeys:used.parent_node )) }</span> *} &nbsp; <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=set&SearchContentClassID=34"><span style="color: #0600FF;">set</span></a> <span style="color: #007700;">submenu</span><span style="color: #66cc66;">=</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=fetch&SearchContentClassID=31"><span style="color: #0600FF;">fetch</span></a><span style="color: #66cc66;">&#40;</span> content, list, <a href="https://ez.no/doc/content/advancedsearch?SearchText=hash&SearchContentClassID=31"><span style="color: #0600FF;">hash</span></a><span style="color: #66cc66;">&#40;</span> parent_node_id, <span style="color: #0000bb;">$DesignKeys:used</span>.<span style="color: #006600;">parent_node</span>, sort_by,<a href="https://ez.no/doc/content/advancedsearch?SearchText=array&SearchContentClassID=31"><span style="color: #0600FF;">array</span></a><span style="color: #66cc66;">&#40;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=array&SearchContentClassID=31"><span style="color: #0600FF;">array</span></a><span style="color: #66cc66;">&#40;</span>priority, <a href="https://ez.no/doc/content/advancedsearch?SearchText=false&SearchContentClassID=31"><span style="color: #0600FF;">false</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#125;</span> &nbsp; <span style="color: #808080; font-style: italic;">{* ##################################################################################### *}</span> <span style="color: #808080; font-style: italic;">{* test: if depth is gt(3), then, use depth as a manipulated placer into longer qry *}</span> <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=section&SearchContentClassID=23"><span style="color: #0600FF;">section</span></a> <span style="color: #007700;">show</span><span style="color: #66cc66;">=</span><span style="color: #0000bb;">$module_result</span>.<span style="color: #006600;">content_info</span>.<span style="color: #006600;">node_depth</span><span style="color: #66cc66;">|</span>gt<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=set&SearchContentClassID=34"><span style="color: #0600FF;">set</span></a> <span style="color: #007700;">current_top_level_node_id</span><span style="color: #66cc66;">=</span><span style="color: #0000bb;">$module_result</span>.<span style="color: #006600;">path</span>.1.<span style="color: #006600;">node_id</span><span style="color: #66cc66;">&#125;</span> &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">{* &lt;br /&gt;Depth gt(3), flag set &nbsp; {set submenu=fetch( content, list, hash( node_id, $current_top_level_node_id )) }</span> <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=set&SearchContentClassID=34"><span style="color: #0600FF;">set</span></a> <span style="color: #007700;">parent</span><span style="color: #66cc66;">=</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=fetch&SearchContentClassID=31"><span style="color: #0600FF;">fetch</span></a><span style="color: #66cc66;">&#40;</span> content, node, <a href="https://ez.no/doc/content/advancedsearch?SearchText=hash&SearchContentClassID=31"><span style="color: #0600FF;">hash</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #dd0000;">'node_id'</span>, <span style="color: #0000bb;">$current_top_level_node_id</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#125;</span> *} &nbsp; <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=set&SearchContentClassID=34"><span style="color: #0600FF;">set</span></a> <span style="color: #007700;">parent</span><span style="color: #66cc66;">=</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=fetch&SearchContentClassID=31"><span style="color: #0600FF;">fetch</span></a><span style="color: #66cc66;">&#40;</span>content, node, <a href="https://ez.no/doc/content/advancedsearch?SearchText=hash&SearchContentClassID=31"><span style="color: #0600FF;">hash</span></a><span style="color: #66cc66;">&#40;</span> node_id, <span style="color: #0000bb;">$current_top_level_node_id</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=set&SearchContentClassID=34"><span style="color: #0600FF;">set</span></a> <span style="color: #007700;">submenu</span><span style="color: #66cc66;">=</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=fetch&SearchContentClassID=31"><span style="color: #0600FF;">fetch</span></a><span style="color: #66cc66;">&#40;</span> content, list, <a href="https://ez.no/doc/content/advancedsearch?SearchText=hash&SearchContentClassID=31"><span style="color: #0600FF;">hash</span></a><span style="color: #66cc66;">&#40;</span> parent_node_id, <span style="color: #0000bb;">$current_top_level_node_id</span>, sort_by,<a href="https://ez.no/doc/content/advancedsearch?SearchText=array&SearchContentClassID=31"><span style="color: #0600FF;">array</span></a><span style="color: #66cc66;">&#40;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=array&SearchContentClassID=31"><span style="color: #0600FF;">array</span></a><span style="color: #66cc66;">&#40;</span>priority, <a href="https://ez.no/doc/content/advancedsearch?SearchText=false&SearchContentClassID=31"><span style="color: #0600FF;">false</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span> &nbsp; <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=section&SearchContentClassID=23"><span style="color: #0600FF;">section</span></a><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=section&SearchContentClassID=23"><span style="color: #0600FF;">section</span></a><span style="color: #66cc66;">&#125;</span> <span style="color: #808080; font-style: italic;">{* &lt;br /&gt;&lt;br /&gt; &nbsp; {$module_result.path.1.node_id}</span> <span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$module_result</span>.<span style="color: #006600;">path</span><span style="color: #66cc66;">|</span>attribute<span style="color: #66cc66;">&#40;</span>show,<span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$parent</span><span style="color: #66cc66;">|</span>attribute<span style="color: #66cc66;">&#40;</span>show,<span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span> *} &nbsp; <span style="color: #808080; font-style: italic;">{* {$module_result.content_info|attribute(show,3)}</span> &lt;br /&gt; <span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$DesignKeys:used</span><span style="color: #66cc66;">|</span>attribute<span style="color: #66cc66;">&#40;</span>show,<span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span> *} &nbsp; <span style="color: #808080; font-style: italic;">{* {$DesignKeys:used|attribute(show,2)}</span> &nbsp; <span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$DesignKeys:used</span><span style="color: #66cc66;">|</span>attribute<span style="color: #66cc66;">&#40;</span>show,<span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span> *} &nbsp; <span style="color: #808080; font-style: italic;">{* ##################################################################################### *}</span> <span style="color: #808080; font-style: italic;">{* Level 1 - 2 : Submenu List {* ##################################################################################### *}</span> &nbsp; <span style="color: #808080; font-style: italic;">{* Don't Show Submenu if on root page *}</span> <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=section&SearchContentClassID=23"><span style="color: #0600FF;">section</span></a> <span style="color: #007700;">show</span><span style="color: #66cc66;">=</span><span style="color: #0000bb;">$module_result</span>.<span style="color: #006600;">node_id</span><span style="color: #66cc66;">|</span>ne<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span> &nbsp; <span style="color: #808080; font-style: italic;">{* Don't show menu if there are no submenu items *}</span> <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=section&SearchContentClassID=23"><span style="color: #0600FF;">section</span></a> <span style="color: #007700;">show</span><span style="color: #66cc66;">=</span><span style="color: #0000bb;">$submenu</span><span style="color: #66cc66;">|</span>count<span style="color: #66cc66;">|</span>gt<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span> &lt;div id=&quot;sectheader&quot; style=&quot;margin-top: 8px;&quot;&gt;&lt;span class=&quot;headerw&quot;&gt;<span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$parent</span>.<span style="color: #006600;">name</span><span style="color: #66cc66;">&#125;</span>&lt;/span&gt;&lt;/div&gt; &nbsp; <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=section&SearchContentClassID=23"><span style="color: #0600FF;">section</span></a> <span style="color: #007700;">var</span><span style="color: #66cc66;">=</span>menu <span style="color: #007700;">loop</span><span style="color: #66cc66;">=</span><span style="color: #0000bb;">$submenu</span><span style="color: #66cc66;">&#125;</span> &nbsp; <span style="color: #808080; font-style: italic;">{* Exclude: Company: Specials Folder *}</span> <span style="color: #66cc66;">&#123;</span>section-exclude <span style="color: #007700;">match</span><span style="color: #66cc66;">=</span><span style="color: #0000bb;">$menu</span>.<span style="color: #006600;">node_id</span><span style="color: #66cc66;">|</span>eq<span style="color: #66cc66;">&#40;</span><span style="color: #0000bb;">$specials_node_id</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span> &nbsp; <span style="color: #808080; font-style: italic;">{* {set children=fetch( content, list, hash( parent_node_id, $menu.node_id, sort_by,array(array(priority, false() )) ))}</span> <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=section&SearchContentClassID=23"><span style="color: #0600FF;">section</span></a> <span style="color: #007700;">show</span><span style="color: #66cc66;">=</span><span style="color: #0000bb;">$children</span><span style="color: #66cc66;">|</span>count<span style="color: #66cc66;">|</span>lt<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span> *} &nbsp; <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=switch&SearchContentClassID=23"><span style="color: #0600FF;">switch</span></a> <span style="color: #007700;">name</span><span style="color: #66cc66;">=</span>selected <span style="color: #007700;">match</span><span style="color: #66cc66;">=</span><span style="color: #0000bb;">$menu</span>.<span style="color: #006600;">node_id</span><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span>case <span style="color: #007700;">match</span><span style="color: #66cc66;">=</span><span style="color: #0000bb;">$module_result</span>.<span style="color: #006600;">node_id</span><span style="color: #66cc66;">&#125;</span> &lt;div class=&quot;sectmain-match&quot;&gt; <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span>case<span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span>case<span style="color: #66cc66;">&#125;</span> &lt;div class=&quot;sectmain&quot;&gt; <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span>case<span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=switch&SearchContentClassID=23"><span style="color: #0600FF;">switch</span></a><span style="color: #66cc66;">&#125;</span> &nbsp; <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=switch&SearchContentClassID=23"><span style="color: #0600FF;">switch</span></a> <span style="color: #007700;">name</span><span style="color: #66cc66;">=</span>selected <span style="color: #007700;">match</span><span style="color: #66cc66;">=</span><span style="color: #0000bb;">$menu</span>.<span style="color: #006600;">node_id</span><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span>case <span style="color: #007700;">match</span><span style="color: #66cc66;">=</span><span style="color: #0000bb;">$module_result</span>.<span style="color: #006600;">node_id</span><span style="color: #66cc66;">&#125;</span> &lt;a href=<span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$menu</span>.<span style="color: #006600;">url_alias</span><span style="color: #66cc66;">|</span>ezroot<span style="color: #66cc66;">&#125;</span> class=&quot;mainb-match&quot;&gt;<span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$menu</span>.<span style="color: #006600;">name</span><span style="color: #66cc66;">|</span>shorten<span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">25</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span>&lt;/a&gt; <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span>case<span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span>case<span style="color: #66cc66;">&#125;</span> &lt;a href=<span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$menu</span>.<span style="color: #006600;">url_alias</span><span style="color: #66cc66;">|</span>ezroot<span style="color: #66cc66;">&#125;</span> class=&quot;mainb&quot;&gt;<span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$menu</span>.<span style="color: #006600;">name</span><span style="color: #66cc66;">|</span>shorten<span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">25</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span>&lt;/a&gt; <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span>case<span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=switch&SearchContentClassID=23"><span style="color: #0600FF;">switch</span></a><span style="color: #66cc66;">&#125;</span> &lt;/div&gt; &nbsp; <span style="color: #808080; font-style: italic;">{* ##################################################################################### *}</span> <span style="color: #808080; font-style: italic;">{* 3rd Level : tertiary (separate) menus {* ##################################################################################### *}</span> <span style="color: #808080; font-style: italic;">{* Don't Show Tertiary if on root page *}</span> &nbsp; <span style="color: #808080; font-style: italic;">{* Exclude: Company: Specials Folder *}</span> <span style="color: #66cc66;">&#123;</span>section-exclude <span style="color: #007700;">match</span><span style="color: #66cc66;">=</span><span style="color: #0000bb;">$menu</span>.<span style="color: #006600;">node_id</span><span style="color: #66cc66;">|</span>eq<span style="color: #66cc66;">&#40;</span><span style="color: #0000bb;">$specials_node_id</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span> &nbsp; <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=set&SearchContentClassID=34"><span style="color: #0600FF;">set</span></a> <span style="color: #007700;">parent</span><span style="color: #66cc66;">=</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=fetch&SearchContentClassID=31"><span style="color: #0600FF;">fetch</span></a><span style="color: #66cc66;">&#40;</span>content, node, <a href="https://ez.no/doc/content/advancedsearch?SearchText=hash&SearchContentClassID=31"><span style="color: #0600FF;">hash</span></a><span style="color: #66cc66;">&#40;</span> node_id, <span style="color: #0000bb;">$menu</span>.<span style="color: #006600;">node_id</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=set&SearchContentClassID=34"><span style="color: #0600FF;">set</span></a> <span style="color: #007700;">tertiary</span><span style="color: #66cc66;">=</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=fetch&SearchContentClassID=31"><span style="color: #0600FF;">fetch</span></a><span style="color: #66cc66;">&#40;</span> content, list, <a href="https://ez.no/doc/content/advancedsearch?SearchText=hash&SearchContentClassID=31"><span style="color: #0600FF;">hash</span></a><span style="color: #66cc66;">&#40;</span> parent_node_id, <span style="color: #0000bb;">$menu</span>.<span style="color: #006600;">node_id</span>, sort_by,<a href="https://ez.no/doc/content/advancedsearch?SearchText=array&SearchContentClassID=31"><span style="color: #0600FF;">array</span></a><span style="color: #66cc66;">&#40;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=array&SearchContentClassID=31"><span style="color: #0600FF;">array</span></a><span style="color: #66cc66;">&#40;</span>priority, <a href="https://ez.no/doc/content/advancedsearch?SearchText=false&SearchContentClassID=31"><span style="color: #0600FF;">false</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span> &nbsp; <span style="color: #808080; font-style: italic;">{* Tertiary Menu *}</span> <span style="color: #808080; font-style: italic;">{* Don't show menu if there are no tertiary items *}</span> <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=section&SearchContentClassID=23"><span style="color: #0600FF;">section</span></a> <span style="color: #007700;">show</span><span style="color: #66cc66;">=</span><span style="color: #0000bb;">$tertiary</span><span style="color: #66cc66;">|</span>count<span style="color: #66cc66;">|</span>gt<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=section&SearchContentClassID=23"><span style="color: #0600FF;">section</span></a> <span style="color: #007700;">var</span><span style="color: #66cc66;">=</span>tmenu <span style="color: #007700;">loop</span><span style="color: #66cc66;">=</span><span style="color: #0000bb;">$tertiary</span><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=section&SearchContentClassID=23"><span style="color: #0600FF;">section</span></a> <span style="color: #007700;">show</span><span style="color: #66cc66;">=</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=or&SearchContentClassID=31"><span style="color: #0600FF;">or</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000bb;">$menu</span>.<span style="color: #006600;">node_id</span><span style="color: #66cc66;">|</span>eq<span style="color: #66cc66;">&#40;</span><span style="color: #0000bb;">$module_result</span>.<span style="color: #006600;">node_id</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #0000bb;">$tmenu</span>.<span style="color: #006600;">node_id</span><span style="color: #66cc66;">|</span>eq<span style="color: #66cc66;">&#40;</span><span style="color: #0000bb;">$module_result</span>.<span style="color: #006600;">node_id</span><span style="color: #66cc66;">&#41;</span>, <a href="https://ez.no/doc/content/advancedsearch?SearchText=and&SearchContentClassID=31"><span style="color: #0600FF;">and</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000bb;">$tmenu</span>.<span style="color: #006600;">parent_node</span> _id<span style="color: #66cc66;">|</span>eq<span style="color: #66cc66;">&#40;</span><span style="color: #0000bb;">$menu</span>.<span style="color: #006600;">node_id</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #0000bb;">$tmenu</span>.<span style="color: #006600;">parent_node_id</span><span style="color: #66cc66;">|</span>eq<span style="color: #66cc66;">&#40;</span><span style="color: #0000bb;">$DesignKeys:used</span>.<span style="color: #006600;">parent_node</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span> <span style="color: #808080; font-style: italic;">{* Exclude: Company: Specials Folder *}</span> <span style="color: #66cc66;">&#123;</span>section-exclude <span style="color: #007700;">match</span><span style="color: #66cc66;">=</span><span style="color: #0000bb;">$tmenu</span>.<span style="color: #006600;">node_id</span><span style="color: #66cc66;">|</span>eq<span style="color: #66cc66;">&#40;</span><span style="color: #0000bb;">$specials_node_id</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=switch&SearchContentClassID=23"><span style="color: #0600FF;">switch</span></a> <span style="color: #007700;">name</span><span style="color: #66cc66;">=</span>selected <span style="color: #007700;">match</span><span style="color: #66cc66;">=</span><span style="color: #0000bb;">$tmenu</span>.<span style="color: #006600;">node_id</span><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span>case <span style="color: #007700;">match</span><span style="color: #66cc66;">=</span><span style="color: #0000bb;">$module_result</span>.<span style="color: #006600;">node_id</span><span style="color: #66cc66;">&#125;</span>&lt;div class=&quot;sectmain-child-match&quot;&gt;<span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span>case<span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span>case<span style="color: #66cc66;">&#125;</span>&lt;div class=&quot;sectmain-child&quot;&gt;<span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span>case<span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=switch&SearchContentClassID=23"><span style="color: #0600FF;">switch</span></a><span style="color: #66cc66;">&#125;</span> &lt;a href=<span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$tmenu</span>.<span style="color: #006600;">url_alias</span><span style="color: #66cc66;">|</span>ezroot<span style="color: #66cc66;">&#125;</span> class=&quot;mainb-child&quot; style=&quot;padding-left: 10px;&quot;&gt;<span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$tmenu</span>.<span style="color: #006600;">name</span><span style="color: #66cc66;">|</span>shorten<span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">25</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span>&lt;/a&gt;&lt;/div&gt; <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=section&SearchContentClassID=23"><span style="color: #0600FF;">section</span></a><span style="color: #66cc66;">&#125;</span> &nbsp; <span style="color: #808080; font-style: italic;">{* End of sub-folder loop. *}</span> <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=section&SearchContentClassID=23"><span style="color: #0600FF;">section</span></a><span style="color: #66cc66;">&#125;</span> &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">{* End of dont' show menu if no menus exist *}</span> <span style="color: #808080; font-style: italic;">{* /section *}</span> &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">{* End of sub-folder loop. *}</span> <span style="color: #808080; font-style: italic;">{* /section *}</span> &nbsp; <span style="color: #808080; font-style: italic;">{* End of dont' show menu on root page *}</span> <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=section&SearchContentClassID=23"><span style="color: #0600FF;">section</span></a><span style="color: #66cc66;">&#125;</span> &nbsp; <span style="color: #808080; font-style: italic;">{* ##################################################################################### *}</span> <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=section&SearchContentClassID=23"><span style="color: #0600FF;">section</span></a><span style="color: #66cc66;">&#125;</span> &nbsp; <span style="color: #808080; font-style: italic;">{* End of sub-folder loop. *}</span> <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=section&SearchContentClassID=23"><span style="color: #0600FF;">section</span></a><span style="color: #66cc66;">&#125;</span> &nbsp; <span style="color: #808080; font-style: italic;">{* End of dont' show menu if no menus exist *}</span> <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=section&SearchContentClassID=23"><span style="color: #0600FF;">section</span></a><span style="color: #66cc66;">&#125;</span> &nbsp; <span style="color: #808080; font-style: italic;">{* End of dont' show menu on root page *}</span> <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=section&SearchContentClassID=23"><span style="color: #0600FF;">section</span></a><span style="color: #66cc66;">&#125;</span> &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=let&SearchContentClassID=34"><span style="color: #0600FF;">let</span></a><span style="color: #66cc66;">&#125;</span> &nbsp; &nbsp; <span style="color: #808080; font-style: italic;">{* ///////////////////////////////////////////////////////////////////// *}</span></pre> Tue, 18 Aug 2009 02:15:06 GMT Template Logic to test if a template variable is defined https://ezpedia.org/snippet/template_logic_to_test_if_a_template_variable_is_defined https://ezpedia.org/snippet/template_logic_to_test_if_a_template_variable_is_defined <div class="object-center"> <p class="editor_motivation">This is a <a href="/es/template/stub">Stub</a> article. Help the eZ Publish community by expanding it!</p></div><a name="eztoc36827_1" id="eztoc36827_1"></a><h2>Question</h2><p>How would one test if a template variable is defined?</p><a name="eztoc36827_2" id="eztoc36827_2"></a><h2>Solution</h2><p>You can use the is_set operator: <a href="https://ez.no/doc/ez_publish/technical_manual/3_8/reference/template_operators/variable_and_type_handling/is_set" title="https://ez.no/doc/ez_publish/technical_manual/3_8/reference/template_operators/variable_and_type_handling/is_set" target="_self">https://ez.no/doc/ez_publish/techn...rs/variable_and_type_handling/is_set</a> </p><a name="eztoc36827_3" id="eztoc36827_3"></a><h2>External reference</h2> <ul> <li><a href="https://ez.no/community/forum/general/how_to_test_for_existance_of_variable#msg116669" title="Posted by: Kristof Coomans: sql seems rather strange to compare with the template language ;-)" target="_self">Forum: How to test for existence of variable</a></li> </ul> Tue, 18 Aug 2009 02:08:19 GMT PHP Snippet Creating new content object versions https://ezpedia.org/snippet/php_snippet_creating_new_content_object_versions https://ezpedia.org/snippet/php_snippet_creating_new_content_object_versions <div class="object-right"><p class="version_info">This is compatible with <a href="/es/ez/ez_publish_4" target="_self">eZ Publish 4</a>.</p></div><p>You can update objects by creating new version and publish the new version.</p><a name="eztoc220281_0_1" id="eztoc220281_0_1"></a><h3>The code</h3><a name="eztoc220281_0_2" id="eztoc220281_0_2"></a><h3>Known variables</h3> <ul> <li>$object, instance of class eZContentObject</li> </ul> <a name="eztoc220281_0_3" id="eztoc220281_0_3"></a><h3>Sample</h3> <pre class="php" style="font-family:monospace;"><span style="color: #000088;">$newVersion</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createNewVersion</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$newData</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetchDataMap</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$newVersion</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'version'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #666666; font-style: italic;">// change attributes of new version here, by using $newData data map</span> &nbsp; <span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> eZOperationHandler<span style="color: #339933;">::</span><span style="color: #004000;">execute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'content'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'publish'</span><span style="color: #339933;">,</span> <a href="https://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'object_id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'id'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'version'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$newVersion</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'version'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre> Tue, 18 Aug 2009 01:55:33 GMT PHP Snippet Fetching ezimage datatype image alias properties https://ezpedia.org/snippet/php_snippet_fetching_ezimage_datatype_image_alias_properties https://ezpedia.org/snippet/php_snippet_fetching_ezimage_datatype_image_alias_properties <div class="object-center"><p class="version_info">This is compatible with <a href="/es/ez/ez_publish_4" target="_self">eZ Publish 4</a>.</p></div> <div class="object-center"> <p class="editor_motivation">This is a <a href="/es/template/stub">Stub</a> article. Help the eZ Publish community by expanding it!</p></div><a name="eztoc226750_1" id="eztoc226750_1"></a><h2>Introduction</h2><p>Did you know that you can use the eZ Publish kernel api to obtain image alias properties from content object attributes which use the ezimage datatype.</p><a name="eztoc226750_2" id="eztoc226750_2"></a><h2>Example</h2><p>This is a simple php example of how you may use the eZ Publish kernel api to obtain image alias properties. This example comes from a simple example custom module view.</p> <pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> &nbsp; <span style="color: #009933; font-style: italic;">/** * File image.php * * @package image.php * @version //autogentag// * @copyright Copyright (C) 2007 Brookins Consulting. All rights reserved. * @license https://www.gnu.org/licenses/gpl.txt GPL License */</span> &nbsp; <span style="color: #000088;">$Module</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$Params</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Module'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #666666; font-style: italic;">// START</span> &nbsp; <span style="color: #666666; font-style: italic;">// Assume this type of module/view url:</span> <span style="color: #666666; font-style: italic;">// www.site.com/myextension/mymodule/myview/1234</span> <span style="color: #666666; font-style: italic;">// 1234 maps to the view parameter, MyNode (eg: $Params[&quot;MyNode&quot;])</span> &nbsp; <span style="color: #666666; font-style: italic;">// 0. Include the necessary files -- I would imagine that some are include</span> &nbsp; <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'kernel/common/template.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #666666; font-style: italic;">// 1. Create an instance of the database</span> <span style="color: #000088;">$db</span> <span style="color: #339933;">=</span> eZDB<span style="color: #339933;">::</span><span style="color: #004000;">instance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #666666; font-style: italic;">// 2. Query the node via node id</span> <span style="color: #000088;">$my_node</span> <span style="color: #339933;">=</span> eZContentObject<span style="color: #339933;">::</span><span style="color: #004000;">fetchByNodeID</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$Params</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;MyNode&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// $my_node = eZContentObject::fetchByNodeID( '86' );</span> &nbsp; <span style="color: #666666; font-style: italic;">// 3. Get a copy of the data_map</span> <span style="color: #000088;">$my_node_data_map</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$my_node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetchDataMap</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #666666; font-style: italic;">// 4. Get a reference to the image</span> <span style="color: #000088;">$my_node_image</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$my_node_data_map</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;image&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// $my_node_image_data = $my_node_image-&gt;DataText;</span> &nbsp; <span style="color: #666666; font-style: italic;">// Example Usage of the eZ Image Alias Handler Class / System</span> <span style="color: #666666; font-style: italic;">// include_once( 'kernel/classes/datatypes/ezimage/ezimagealiashandler.php' );</span> &nbsp; <span style="color: #666666; font-style: italic;">// 5. Fetch Alias Handler</span> <span style="color: #000088;">$image_alias_handler</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> eZImageAliasHandler<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$my_node_image</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #666666; font-style: italic;">// 6. Fetch Alias Attributes*</span> &nbsp; <span style="color: #666666; font-style: italic;">// 7. Fetch Original Image Path as URI</span> <span style="color: #000088;">$my_node_image_uri</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$image_alias_handler</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attributeFromOriginal</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'url'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #666666; font-style: italic;">// 8. Fetch Original Image Dimentions</span> <span style="color: #000088;">$my_node_image_width</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$image_alias_handler</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attributeFromOriginal</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'width'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$my_node_image_height</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$image_alias_handler</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attributeFromOriginal</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'height'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #666666; font-style: italic;">// 9. Get the associated link</span> <span style="color: #000088;">$my_node_link_object</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$my_node_data_map</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;my_link&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$my_node_link_url_object</span> <span style="color: #339933;">=</span> eZURL<span style="color: #339933;">::</span><span style="color: #004000;">fetch</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$my_node_link_object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">DataInt</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$my_node_link_url</span><span style="color: #339933;">=</span><a href="https://www.php.net/str_replace"><span style="color: #990000;">str_replace</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;+&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$my_node_link_url_object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'url'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #666666; font-style: italic;">// 10. Instantiate the template and set the template vars</span> <span style="color: #000088;">$tpl</span> <span style="color: #339933;">=</span> templateInit<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$tpl</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setVariable</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'parameters'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$Params</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$tpl</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setVariable</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'my_node_image_path'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$my_node_image_uri</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$tpl</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setVariable</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'my_node_image_width'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$my_node_image_width</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$tpl</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setVariable</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'my_node_image_height'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$my_node_image_height</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$tpl</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setVariable</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'my_node_link_url'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$my_node_link_url</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #666666; font-style: italic;">// END</span> &nbsp; <span style="color: #666666; font-style: italic;">// phpinfo();</span> eZExecution<span style="color: #339933;">::</span><span style="color: #004000;">cleanExit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000000; font-weight: bold;">?&gt;</span></pre><a name="eztoc226750_3" id="eztoc226750_3"></a><h2>References</h2> <ul> <li><a href="/es/ez/image_alias_handler" target="_self">ezimagealiashandler</a></li> </ul> Tue, 18 Aug 2009 01:55:05 GMT PHP Snippet Creating new content object language translations https://ezpedia.org/snippet/php_snippet_creating_new_content_object_language_translations https://ezpedia.org/snippet/php_snippet_creating_new_content_object_language_translations <div class="object-center"> <p class="editor_motivation">This is a <a href="/es/template/stub">Stub</a> article. Help the eZ Publish community by expanding it!</p></div><a name="eztoc365417_1" id="eztoc365417_1"></a><h2>About</h2><p>Incomplete entry</p><a name="eztoc365417_2" id="eztoc365417_2"></a><h2>References</h2> <ul> <li>N/A</li> </ul> Tue, 18 Aug 2009 01:54:05 GMT PHP Snippet Copying objects https://ezpedia.org/snippet/php_snippet_copying_objects https://ezpedia.org/snippet/php_snippet_copying_objects <div class="object-right"><p class="version_info">This is compatible with <a href="/es/ez/ez_publish_4" target="_self">eZ Publish 4</a>.</p></div><a name="eztoc359_1" id="eztoc359_1"></a><h2>Code sample</h2><p>The following code copies an existing object and gives it one location in the node tree. It was taken from the copy view of the content module (kernel/content/copy.php).</p><p>The used variables are:</p> <ul> <li>$object: instance of eZContentObject you want to copy</li> <li>$newParentNodeID: node id of the parent for the new object</li> <li>$allVersions: true if you want to copy all versions of the object to the new object, false if you only want to copy the currently published version</li> </ul> <pre class="php" style="font-family:monospace;"><span style="color: #000088;">$db</span> <span style="color: #339933;">=</span> eZDB<span style="color: #339933;">::</span><span style="color: #004000;">instance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">begin</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$newObject</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">copy</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$allVersions</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$curVersion</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$newObject</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'current_version'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$curVersionObject</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$newObject</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'current'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$newObjAssignments</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$curVersionObject</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'node_assignments'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <a href="https://www.php.net/unset"><span style="color: #990000;">unset</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$curVersionObject</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #666666; font-style: italic;">// remove old node assignments</span> <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$newObjAssignments</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$assignment</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$assignment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">purge</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> &nbsp; <span style="color: #666666; font-style: italic;">// and create a new one</span> <span style="color: #000088;">$nodeAssignment</span> <span style="color: #339933;">=</span> eZNodeAssignment<span style="color: #339933;">::</span><span style="color: #004000;">create</span><span style="color: #009900;">&#40;</span> <a href="https://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'contentobject_id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$newObject</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'id'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'contentobject_version'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$curVersion</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'parent_node'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$newParentNodeID</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'is_main'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$nodeAssignment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">store</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #666666; font-style: italic;">// publish the newly created object</span> <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'lib/ezutils/classes/ezoperationhandler.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> eZOperationHandler<span style="color: #339933;">::</span><span style="color: #004000;">execute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'content'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'publish'</span><span style="color: #339933;">,</span> <a href="https://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'object_id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$newObject</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'id'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'version'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$curVersion</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Update &quot;is_invisible&quot; attribute for the newly created node.</span> <span style="color: #000088;">$newNode</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$newObject</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'main_node'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> eZContentObjectTreeNode<span style="color: #339933;">::</span><span style="color: #004000;">updateNodeVisibility</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$newNode</span><span style="color: #339933;">,</span> <span style="color: #000088;">$newParentNode</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">commit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre> Tue, 18 Aug 2009 01:51:09 GMT PHP Snippet Assigning sections https://ezpedia.org/snippet/php_snippet_assigning_sections https://ezpedia.org/snippet/php_snippet_assigning_sections <div class="object-right"><p class="version_info">This is compatible with <a href="/es/ez/ez_publish_4" target="_self">eZ Publish 4</a>.</p></div> <div class="object-center"> <p class="editor_motivation">This is a <a href="/es/template/stub">Stub</a> article. Help the eZ Publish community by expanding it!</p></div><a name="eztoc198253_1" id="eztoc198253_1"></a><h2>To a subtree</h2> <pre class="php" style="font-family:monospace;">eZContentObjectTreeNode<span style="color: #339933;">::</span><span style="color: #004000;">assignSectionToSubTree</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$nodeID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$sectionID</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> eZContentCacheManager<span style="color: #339933;">::</span><span style="color: #004000;">clearAllContentCache</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre><a name="eztoc198253_2" id="eztoc198253_2"></a><h2>To a single node</h2> <pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Missing example</span></pre> Tue, 18 Aug 2009 01:49:24 GMT PHP Snippet Assigning roles https://ezpedia.org/snippet/php_snippet_assigning_roles https://ezpedia.org/snippet/php_snippet_assigning_roles <div class="object-right"><p class="version_info">This is compatible with <a href="/es/ez/ez_publish_4" target="_self">eZ Publish 4</a>.</p></div> <div class="object-center"> <p class="editor_motivation">This is a <a href="/es/template/stub">Stub</a> article. Help the eZ Publish community by expanding it!</p></div><a name="eztoc208141_1" id="eztoc208141_1"></a><h2>Predefined variables</h2> <ul> <li>$roleID: ID of the role</li> <li>$objectID: id of a user or user group content object you want to assign the role to</li> <li>$limitIdent: either null, Subtree or Section</li> <li>$limitValue: either null, a node path string (in case $limitIdent is 'Subtree') or a section id (in case $limitIdent is 'Section')</li> </ul> <pre class="php" style="font-family:monospace;"><span style="color: #000088;">$role</span> <span style="color: #339933;">=</span> eZRole<span style="color: #339933;">::</span><span style="color: #004000;">fetch</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$roleID</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$role</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">assignToUser</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$objectID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$limitIdent</span><span style="color: #339933;">,</span> <span style="color: #000088;">$limitValue</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; eZRole<span style="color: #339933;">::</span><span style="color: #004000;">expireCache</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> eZContentCacheManager<span style="color: #339933;">::</span><span style="color: #004000;">clearAllContentCache</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> eZUser<span style="color: #339933;">::</span><span style="color: #004000;">cleanupCache</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre> Tue, 18 Aug 2009 01:48:57 GMT PHP Snippet Adding subtree notification rules https://ezpedia.org/snippet/php_snippet_adding_subtree_notification_rules https://ezpedia.org/snippet/php_snippet_adding_subtree_notification_rules <div class="object-right"><p class="version_info">This is compatible with <a href="/es/ez/ez_publish_4" target="_self">eZ Publish 4</a>.</p></div> <div class="object-center"> <p class="editor_motivation">This is a <a href="/es/template/stub">Stub</a> article. Help the eZ Publish community by expanding it!</p></div><a name="eztoc58899_1" id="eztoc58899_1"></a><h2>Code sample</h2><p>The defined variables are:</p> <ul> <li>$nodeID: id of the node for which we want to add a subtree notification rule</li> <li>$userID: id of the user for which we want to add the notification rule</li> </ul> <pre class="php" style="font-family:monospace;">&nbsp; <span style="color: #000088;">$nodeIDList</span> <span style="color: #339933;">=</span> eZSubtreeNotificationRule<span style="color: #339933;">::</span><span style="color: #004000;">fetchNodesForUserID</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$userID</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">false</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><a href="https://www.php.net/in_array"><span style="color: #990000;">in_array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$nodeID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$nodeIDList</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$rule</span> <span style="color: #339933;">=&amp;</span> eZSubtreeNotificationRule<span style="color: #339933;">::</span><span style="color: #004000;">create</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$nodeID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$userID</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$rule</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">store</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span></pre> Tue, 18 Aug 2009 01:48:34 GMT PHP Snippet Add Location to Object / Add Usergroup to User https://ezpedia.org/snippet/php_snippet_add_location_to_object_add_usergroup_to_user https://ezpedia.org/snippet/php_snippet_add_location_to_object_add_usergroup_to_user <div class="object-right"><p class="version_info">This is compatible with <a href="/es/ez/ez_publish_4" target="_self">eZ Publish 4</a>.</p></div><a name="eztoc262412_1" id="eztoc262412_1"></a><h2>Compatibility</h2><p>This example works with eZ Publish 4.x</p><a name="eztoc262412_2" id="eztoc262412_2"></a><h2>About</h2><p>This function allows adding a location to an extisting object even adds a usergroup to an existing user. The Code was taken and modified from kernel/content/action.php where it says &quot; if ( $module-&gt;isCurrentAction( 'AddAssignment' ) )&quot;</p><a name="eztoc262412_3" id="eztoc262412_3"></a><h2>Example</h2> <pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/** * Adds User to the chosen Usergroup * objectID=UserobjectID * newNodeID=usergroupNodeID * @param integer $objectID * @param unknown_type $newNodeID */</span> <span style="color: #000000; font-weight: bold;">function</span> addLocation<span style="color: #009900;">&#40;</span><span style="color: #000088;">$objectID</span><span style="color: #339933;">,</span><span style="color: #000088;">$newNodeID</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">//$selectedNodeIDArray = eZContentBrowse::result( 'AddNodeAssignment' );</span> eZDebug<span style="color: #339933;">::</span><span style="color: #004000;">writeDebug</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;LocationAdd: objectID&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$objectID</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>newNodeID: &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$newNodeID</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$object</span> <span style="color: #339933;">=</span> eZContentObject<span style="color: #339933;">::</span><span style="color: #004000;">fetch</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$objectID</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$nodeID</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;main_node_id&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//$version = $object-&gt;currentVersion();</span> <span style="color: #000088;">$ini</span> <span style="color: #339933;">=</span> eZINI<span style="color: #339933;">::</span><span style="color: #004000;">instance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$userClassID</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$ini</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">variable</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;UserSettings&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;UserClassID&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// $node = eZContentObjectTreeNode::fetch( $nodeID );</span> <span style="color: #000088;">$selectedNodeIDArray</span> <span style="color: #339933;">=</span> <a href="https://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$newNodeID</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$node</span> <span style="color: #339933;">=</span> eZContentObjectTreeNode<span style="color: #339933;">::</span><span style="color: #004000;">fetch</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$selectedNodeIDArray</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><a href="https://www.php.net/is_array"><span style="color: #990000;">is_array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$selectedNodeIDArray</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #000088;">$selectedNodeIDArray</span> <span style="color: #339933;">=</span> <a href="https://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$nodeAssignmentList</span> <span style="color: #339933;">=</span> eZNodeAssignment<span style="color: #339933;">::</span><span style="color: #004000;">fetchForObject</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$objectID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'current_version'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">false</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$assignedNodes</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">assignedNodes</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$parentNodeIDArray</span> <span style="color: #339933;">=</span> <a href="https://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$setMainNode</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #339933;">;</span> <span style="color: #000088;">$hasMainNode</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$assignedNodes</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$assignedNode</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$assignedNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'is_main'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #000088;">$hasMainNode</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$append</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$nodeAssignmentList</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$nodeAssignment</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$nodeAssignment</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'parent_node'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$assignedNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'parent_node_id'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$append</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$append</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$parentNodeIDArray</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$assignedNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'parent_node_id'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #000088;">$hasMainNode</span> <span style="color: #009900;">&#41;</span> <span style="color: #000088;">$setMainNode</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$existingNode</span> <span style="color: #339933;">=</span> eZContentObjectTreeNode<span style="color: #339933;">::</span><span style="color: #004000;">fetch</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$nodeID</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$mainNodeID</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$existingNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'main_node_id'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$objectName</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'name'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$db</span> <span style="color: #339933;">=</span> eZDB<span style="color: #339933;">::</span><span style="color: #004000;">instance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">begin</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$locationAdded</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #339933;">;</span> <span style="color: #000088;">$node</span> <span style="color: #339933;">=</span> eZContentObjectTreeNode<span style="color: #339933;">::</span><span style="color: #004000;">fetch</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$nodeID</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$selectedNodeIDArray</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$selectedNodeID</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><a href="https://www.php.net/in_array"><span style="color: #990000;">in_array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$selectedNodeID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$parentNodeIDArray</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$parentNode</span> <span style="color: #339933;">=</span> eZContentObjectTreeNode<span style="color: #339933;">::</span><span style="color: #004000;">fetch</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$selectedNodeID</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$parentNodeObject</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$parentNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'object'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #666666; font-style: italic;">/*$canCreate = ( ( $parentNode-&gt;checkAccess( 'create', $class-&gt;attribute( 'id' ), $parentNodeObject-&gt;attribute( 'contentclass_id' ) ) == 1 ) || ( $parentNode-&gt;canAddLocation() &amp;&amp; $node-&gt;canRead() ) );*/</span> <span style="color: #000088;">$canCreate</span><span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">true</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$canCreate</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$insertedNode</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addLocation</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$selectedNodeID</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">true</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #666666; font-style: italic;">// Now set is as published and fix main_node_id</span> <span style="color: #000088;">$insertedNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAttribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'contentobject_is_published'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$insertedNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAttribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'main_node_id'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'main_node_id'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$insertedNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAttribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'contentobject_version'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'contentobject_version'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Make sure the url alias is set updated.</span> <span style="color: #000088;">$insertedNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">updateSubTreePath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$insertedNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">sync</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$locationAdded</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$locationAdded</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'contentclass_id'</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$userClassID</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> eZUser<span style="color: #339933;">::</span><span style="color: #004000;">cleanupCache</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span> <span style="color: #000088;">$db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">commit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #666666; font-style: italic;">//include_once( 'kernel/classes/ezcontentcachemanager.php' );</span> eZContentCacheManager<span style="color: #339933;">::</span><span style="color: #004000;">clearContentCacheIfNeeded</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$objectID</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #009900;">&#125;</span></pre> Tue, 18 Aug 2009 01:48:11 GMT PHP Snippet Adding collaboration notification rules https://ezpedia.org/snippet/php_snippet_adding_collaboration_notification_rules https://ezpedia.org/snippet/php_snippet_adding_collaboration_notification_rules <div class="object-right"><p class="version_info">This is compatible with <a href="/es/ez/ez_publish_4" target="_self">eZ Publish 4</a>.</p></div> <div class="object-center"> <p class="editor_motivation">This is a <a href="/es/template/stub">Stub</a> article. Help the eZ Publish community by expanding it!</p></div><p>The following <a href="/es/snippet/php_ez_publish_api_source_code_examples" target="_self">code sample</a> shows you how to create a new collaboration notification rule for a specific user. The known variables are:</p> <ul> <li>$collaborationIdentifier: identifier of the collaboration type, for example <i>ezapprove</i></li> <li>$userID: the content object id of the user we want to create the rule for</li> </ul> <pre class="php" style="font-family:monospace;"><span style="color: #000088;">$existing</span> <span style="color: #339933;">=</span> eZCollaborationNotificationRule<span style="color: #339933;">::</span><span style="color: #004000;">fetchItemTypeList</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$collaborationIdentifier</span><span style="color: #339933;">,</span> <a href="https://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$userID</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <a href="https://www.php.net/count"><span style="color: #990000;">count</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$existing</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$rule</span> <span style="color: #339933;">=</span> eZCollaborationNotificationRule<span style="color: #339933;">::</span><span style="color: #004000;">create</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$collaborationIdentifier</span><span style="color: #339933;">,</span> <span style="color: #000088;">$userID</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$rule</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">store</span><span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span></pre> Tue, 18 Aug 2009 01:47:41 GMT PHP Snippet Adding additional locations for an object https://ezpedia.org/snippet/php_snippet_adding_additional_locations_for_an_object https://ezpedia.org/snippet/php_snippet_adding_additional_locations_for_an_object <div class="object-right"><p class="version_info_ezp3">This is compatible with <a href="/es/ez/ez_publish_3" target="_self">eZ Publish 3</a>.</p></div><a name="eztoc394_1" id="eztoc394_1"></a><h2>Compatibility</h2><p>The code above works with eZ publish <a href="/es/ez/ez_publish_3_8" target="_self">3.8</a> and <a href="/es/ez/ez_publish_3_9" target="_self">3.9</a>.</p><a name="eztoc394_2" id="eztoc394_2"></a><h2>Policy checking</h2><p>You can remove policy checking by removing the conditional structures with $canManageLocations and $canCreate</p><a name="eztoc394_3" id="eztoc394_3"></a><h2>Code sample</h2><p>Since eZ publish 3.8, the publish operation doesn't need to be executed anymore when adding new locations for objects which are already in the node tree.</p><p>The following code was based on a part of the action view of the content module (kernel/content/action.php). The known variables are:</p> <ul> <li>$node: instance of eZContentObjectTreeNode, which holds the object we want to create new tree leaves for</li> <li>$selectedNodeIDArray: array with the node ID's of the additional parent nodes</li> </ul> <pre class="php" style="font-family:monospace;"><span style="color: #000088;">$object</span> <span style="color: #339933;">=&amp;</span> <span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'object'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$objectID</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'id'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'kernel/classes/datatypes/ezuser/ezuser.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$user</span> <span style="color: #339933;">=&amp;</span> eZUser<span style="color: #339933;">::</span><span style="color: #004000;">currentUser</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$canManageLocations</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">checkAccess</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'edit'</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'has_manage_locations'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$canManageLocations</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> &nbsp; <span style="color: #000088;">$nodeAssignmentList</span> <span style="color: #339933;">=</span> eZNodeAssignment<span style="color: #339933;">::</span><span style="color: #004000;">fetchForObject</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$objectID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'current_version'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">false</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$assignedNodes</span> <span style="color: #339933;">=&amp;</span> <span style="color: #000088;">$object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">assignedNodes</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$objectID</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'id'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$parentNodeIDArray</span> <span style="color: #339933;">=</span> <a href="https://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$setMainNode</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #339933;">;</span> <span style="color: #000088;">$hasMainNode</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$assignedNodes</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$assignedNode</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$assignedNodeID</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$assignedNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'node_id'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$assignedNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'is_main'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$hasMainNode</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> &nbsp; <span style="color: #000088;">$append</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$nodeAssignmentList</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$nodeAssignment</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$nodeAssignment</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'parent_node'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$assignedNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'parent_node_id'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$append</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$append</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$parentNodeIDArray</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$assignedNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'parent_node_id'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span> &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #000088;">$hasMainNode</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$setMainNode</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> &nbsp; <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'lib/ezdb/classes/ezdb.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$db</span> <span style="color: #339933;">=&amp;</span> eZDB<span style="color: #339933;">::</span><span style="color: #004000;">instance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">begin</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$locationAdded</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$selectedNodeIDArray</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$selectedNodeID</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><a href="https://www.php.net/in_array"><span style="color: #990000;">in_array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$selectedNodeID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$parentNodeIDArray</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$parentNode</span> <span style="color: #339933;">=</span> eZContentObjectTreeNode<span style="color: #339933;">::</span><span style="color: #004000;">fetch</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$selectedNodeID</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$parentNodeObject</span> <span style="color: #339933;">=&amp;</span> <span style="color: #000088;">$parentNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'object'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$canCreate</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$parentNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">checkAccess</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'create'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'contentclass_id'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$parentNodeObject</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'contentclass_id'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$parentNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">canAddLocation</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">canRead</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$canCreate</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$insertedNode</span> <span style="color: #339933;">=&amp;</span> <span style="color: #000088;">$object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addLocation</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$selectedNodeID</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">true</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #666666; font-style: italic;">// Now set is as published and fix main_node_id</span> <span style="color: #000088;">$insertedNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAttribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'contentobject_is_published'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$insertedNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAttribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'main_node_id'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'main_node_id'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$insertedNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAttribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'contentobject_version'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'contentobject_version'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Make sure the path_identification_string is set correctly.</span> <span style="color: #000088;">$insertedNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">updateSubTreePath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$insertedNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">sync</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$locationAdded</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span> &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$locationAdded</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'lib/ezutils/classes/ezini.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$ini</span> <span style="color: #339933;">=&amp;</span> eZINI<span style="color: #339933;">::</span><span style="color: #004000;">instance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$userClassID</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$ini</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">variable</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;UserSettings&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;UserClassID&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'contentclass_id'</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$userClassID</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> eZUser<span style="color: #339933;">::</span><span style="color: #004000;">cleanupCache</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span> <span style="color: #000088;">$db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">commit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'kernel/classes/ezcontentcachemanager.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> eZContentCacheManager<span style="color: #339933;">::</span><span style="color: #004000;">clearContentCacheIfNeeded</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$objectID</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span></pre> Tue, 18 Aug 2009 01:47:24 GMT PHP Snippet Clearning in-memory object cache https://ezpedia.org/snippet/php_snippet_clearning_in_memory_object_cache https://ezpedia.org/snippet/php_snippet_clearning_in_memory_object_cache <div class="object-center"><p class="version_info">This is compatible with <a href="/es/ez/ez_publish_4" target="_self">eZ Publish 4</a>.</p></div><a name="eztoc426_1" id="eztoc426_1"></a><h2>Clearing the cache</h2><p>When looping over a big amount of content objects or tree nodes, fetch them in cycles of 100 or less and after each cycle, clear the in-memory object cache:</p> <pre class="php" style="font-family:monospace;">eZContentObject<span style="color: #339933;">::</span><span style="color: #004000;">clearCache</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre><a name="eztoc426_2" id="eztoc426_2"></a><h2>External resources</h2> <ul> <li><a href="https://ez.no/community/bugs/memory_leak_in_updatemultilingual_php" target="_self">Bug: memory leakage in updatemultilingual.php</a></li> </ul> Tue, 18 Aug 2009 01:46:46 GMT PHP Snippet Logging in a specific user https://ezpedia.org/snippet/php_snippet_logging_in_a_specific_user https://ezpedia.org/snippet/php_snippet_logging_in_a_specific_user <div class="object-right"><p class="version_info">This is compatible with <a href="/es/ez/ez_publish_4" target="_self">eZ Publish 4</a>.</p></div><a name="eztoc406_1" id="eztoc406_1"></a><h2>Code sample</h2><p>The following code will login the user with the login specified by <i>$login</i>. It is especially useful in cronjob scripts when you need sufficient privileges.</p> <pre class="php" style="font-family:monospace;"><span style="color: #000088;">$user</span> <span style="color: #339933;">=</span> eZUser<span style="color: #339933;">::</span><span style="color: #004000;">fetchByName</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$login</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$userID</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'contentobject_id'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> eZUser<span style="color: #339933;">::</span><span style="color: #004000;">setCurrentlyLoggedInUser</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$user</span><span style="color: #339933;">,</span> <span style="color: #000088;">$userID</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre><a name="eztoc406_2" id="eztoc406_2"></a><h2>Compatibility</h2><p>In all recent versions of eZ publish the content/read policy limitation list of the current user gets cached in a global array by eZContentObjectTreeNode. When switching users, this cache isn't cleared. This issue has been reported as <a href="https://ez.no/community/bugs/cache_for_content_read_limitation_list_isn_t_cleared_after_switching_users" target="_self">bug 8388 at ez.no</a> and fixed in eZ Publish 4.1.x.</p><p>For your reference you can workaround this problem by clearing the cache yourself with the following code:</p> <pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <a href="https://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'ezpolicylimitation_list'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'content'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'read'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <a href="https://www.php.net/unset"><span style="color: #990000;">unset</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'ezpolicylimitation_list'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'content'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'read'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span></pre> Tue, 18 Aug 2009 01:45:42 GMT PHP Snippet Moving a node https://ezpedia.org/snippet/php_snippet_moving_a_node https://ezpedia.org/snippet/php_snippet_moving_a_node <div class="object-right"><p class="version_info">This is compatible with <a href="/es/ez/ez_publish_4" target="_self">eZ Publish 4</a>.</p></div><a name="eztoc91656_1" id="eztoc91656_1"></a><h2>Policy checking</h2><p>You can remove policy checking by removing the condition with <i>$node-&gt;canMoveFrom() &amp;&amp; $newParentNode-&gt;canMoveTo( $classID )</i>.</p><a name="eztoc91656_2" id="eztoc91656_2"></a><h2>Code sample</h2><p>The following code is based on a part of the action view of the content module (kernel/content/action.php). The known variables are:</p> <ul> <li>$node: the node we're trying to move</li> <li>$newParentNode: the destination node we want to place our node under</li> </ul> <pre class="php" style="font-family:monospace;"><span style="color: #000088;">$object</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">object</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$class</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">contentClass</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$classID</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$class</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'id'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><a href="https://www.php.net/in_array"><span style="color: #990000;">in_array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'node_id'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$newParentNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">pathArray</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">canMoveFrom</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$newParentNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">canMoveTo</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$classID</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> eZContentObjectTreeNodeOperations<span style="color: #339933;">::</span><span style="color: #004000;">move</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'node_id'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$newParentNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'node_id'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span></pre> Tue, 18 Aug 2009 01:45:16 GMT PHP Script to delete all nodes under a node in content structure https://ezpedia.org/snippet/php_script_to_delete_all_nodes_under_a_node_in_content_structure https://ezpedia.org/snippet/php_script_to_delete_all_nodes_under_a_node_in_content_structure <div class="object-right"><p class="version_info">This is compatible with <a href="/es/ez/ez_publish_4" target="_self">eZ Publish 4</a>.</p></div><a name="eztoc52343_1" id="eztoc52343_1"></a><h2>About</h2><p> This is a script to delete all nodes under some tree.<br />Please note that this script may use large amounts of memory.</p><p>A better solution has been developed called, 'batchtool'. Try using <a href="https://projects.ez.no/batchtool" target="_self">batchtool</a> instead of this script snippet example.</p><a name="eztoc52343_2" id="eztoc52343_2"></a><h2>Source</h2> <pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> &nbsp; <span style="color: #b1b100;">require</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'autoload.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000000; font-weight: bold;">function</span> deleteNodes<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$classID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$parentNodeID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$depth</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <a href="https://www.php.net/global"><span style="color: #990000;">global</span></a> <span style="color: #000088;">$db</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$deleteIDArray</span> <span style="color: #339933;">=</span> <a href="https://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$nodeArray</span> <span style="color: #339933;">=&amp;</span> eZContentObjectTreeNode<span style="color: #339933;">::</span><span style="color: #004000;">subTree</span><span style="color: #009900;">&#40;</span> <a href="https://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'ClassFilterType'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'include'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'ClassFilterArray'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$classID</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Depth'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$depth</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$parentNodeID</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <a href="https://www.php.net/print"><span style="color: #990000;">print</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Deleting &quot;</span> <span style="color: #339933;">.</span> <a href="https://www.php.net/count"><span style="color: #990000;">count</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$nodeArray</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; nodes. If that is not what you want it would be good to press ctrl-c now.. deleting starts in 20 seconds!!<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <a href="https://www.php.net/sleep"><span style="color: #990000;">sleep</span></a><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">20</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$deletecount</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$deleteIDArray</span> <span style="color: #339933;">=</span> <a href="https://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$nodeArray</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$node</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <a href="https://www.php.net/print"><span style="color: #990000;">print</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Deleting node &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'main_node_id'</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">' , &quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'url_alias'</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;'<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> eZContentObjectTreeNode<span style="color: #339933;">::</span><span style="color: #004000;">removeSubtrees</span><span style="color: #009900;">&#40;</span> <a href="https://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'main_node_id'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">false</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$deletecount</span><span style="color: #339933;">++;</span> <a href="https://www.php.net/print"><span style="color: #990000;">print</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$deletecount</span>, &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span> &nbsp; <span style="color: #000088;">$cli</span> <span style="color: #339933;">=</span> eZCLI<span style="color: #339933;">::</span><span style="color: #004000;">instance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #666666; font-style: italic;">// change the admin-password! see below ...</span> &nbsp; <span style="color: #000088;">$script</span> <span style="color: #339933;">=</span> eZScript<span style="color: #339933;">::</span><span style="color: #004000;">instance</span><span style="color: #009900;">&#40;</span> <a href="https://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'description'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;delete nodes ...<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;delete main nodes ...,<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'use-session'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'use-modules'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'use-extensions'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'user'</span> <span style="color: #339933;">=&gt;</span> <a href="https://www.php.net/array"><span style="color: #990000;">array</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'login'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'admin'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'password'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'ADMINPASS'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$script</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">startup</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$options</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$script</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getOptions</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$script</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">initialize</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <a href="https://www.php.net/set_time_limit"><span style="color: #990000;">set_time_limit</span></a><span style="color: #009900;">&#40;</span> <span style="color: #cc66cc;">0</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// 'deleteNodes' function, used to remove all nodes under passed node_id</span> <span style="color: #666666; font-style: italic;">// example usage of 'deleteNodes' function: deleteNodes( $classID, $parentNodeID, $depth )</span> &nbsp; deleteNodes<span style="color: #009900;">&#40;</span> <a href="https://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'article'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">6713</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">10</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000000; font-weight: bold;">?&gt;</span></pre> Tue, 18 Aug 2009 01:44:15 GMT Template logic to conditionally hide parts of layout using css https://ezpedia.org/snippet/template_logic_to_conditionally_hide_parts_of_layout_using_css https://ezpedia.org/snippet/template_logic_to_conditionally_hide_parts_of_layout_using_css <a name="eztoc499_1" id="eztoc499_1"></a><h2>About</h2><p>Solution which will conditionally hide parts of layout using css while in edit mode.</p><p>From: <i>zurgutt</i> </p><a name="eztoc499_2" id="eztoc499_2"></a><h2>Example</h2><p>Add this in beginning of pagelayout.tpl </p> <pre class="eztemplate" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">{* define a style by context which can be used to hide elements in each mode (navigation, edit, browse etc.) *}</span> &lt;style&gt; .context-hideon-<span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$module_result</span>.<span style="color: #006600;">ui_context</span><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=literal&SearchContentClassID=34"><span style="color: #0600FF;">literal</span></a><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span> display: none; <span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=literal&SearchContentClassID=34"><span style="color: #0600FF;">literal</span></a><span style="color: #66cc66;">&#125;</span> &lt;/style&gt;</pre><p>and then you’ll be able to do something like this </p> <pre class="eztemplate" style="font-family:monospace;">&lt;div id=&quot;leftmenu&quot; class=&quot;context-hideon-edit&quot;&gt; .. some menu here you dont need while editing content .. &lt;/div&gt;</pre><p>Can be achieved by overriding templates but hey much cleaner this way. </p> Mon, 17 Aug 2009 08:15:30 GMT Template logic to display user session switching html form https://ezpedia.org/snippet/template_logic_to_display_user_session_switching_html_form https://ezpedia.org/snippet/template_logic_to_display_user_session_switching_html_form <a name="eztoc750_1" id="eztoc750_1"></a><h2>About</h2><p>If a user is logged in, display their name + logout button, if not, than display a login form.</p><p><i>Submited via irc by Lukasz Serwatka</i></p> <pre class="eztemplate" style="font-family:monospace;"><span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=let&SearchContentClassID=34"><span style="color: #0600FF;">let</span></a> <span style="color: #007700;">thisuser</span><span style="color: #66cc66;">=</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=fetch&SearchContentClassID=31"><span style="color: #0600FF;">fetch</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #dd0000;">'user'</span>,<span style="color: #dd0000;">'current_user'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=section&SearchContentClassID=23"><span style="color: #0600FF;">section</span></a> <span style="color: #007700;">show</span><span style="color: #66cc66;">=</span><span style="color: #0000bb;">$thisuser</span>.<span style="color: #006600;">is_logged_in</span><span style="color: #66cc66;">&#125;</span> &lt;p&gt;Welcome. You are logged in as <span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$thisuser</span>.<span style="color: #006600;">contentobject</span>.<span style="color: #006600;">name</span><span style="color: #66cc66;">&#125;</span>&lt;/p&gt; &lt;p&gt;&lt;a href=&quot;/user/logout&quot;&gt;Logout&lt;/a&gt;&lt;/p&gt; <span style="color: #66cc66;">&#123;</span>section-else<span style="color: #66cc66;">&#125;</span> &lt;!-- login form goes here --&gt; <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=section&SearchContentClassID=23"><span style="color: #0600FF;">section</span></a><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=let&SearchContentClassID=34"><span style="color: #0600FF;">let</span></a><span style="color: #66cc66;">&#125;</span></pre> Mon, 17 Aug 2009 07:43:33 GMT Template logic to display dynamic left menu https://ezpedia.org/snippet/template_logic_to_display_dynamic_left_menu https://ezpedia.org/snippet/template_logic_to_display_dynamic_left_menu <p>I found that another user used this source code with success in the forums, so I thought we all might benefit from the documentation.</p><a name="eztoc918_1" id="eztoc918_1"></a><h2>Question</h2><p>I made up a site using a top and a left menu. In the left one there is only one menu level shown. Now I want the next level been shown, too.</p><a name="eztoc918_2" id="eztoc918_2"></a><h2>Answer</h2><p>You could try something like this</p> <pre class="eztemplate" style="font-family:monospace;"><span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=def&SearchContentClassID=34"><span style="color: #0600FF;">def</span></a> <span style="color: #0000bb;">$second_level_children</span><span style="color: #66cc66;">=</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=array&SearchContentClassID=31"><span style="color: #0600FF;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=def&SearchContentClassID=34"><span style="color: #0600FF;">def</span></a> <span style="color: #0000bb;">$root_node_children</span><span style="color: #66cc66;">=</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=fetch&SearchContentClassID=31"><span style="color: #0600FF;">fetch</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #dd0000;">'content'</span>, <span style="color: #dd0000;">'list'</span>, <a href="https://ez.no/doc/content/advancedsearch?SearchText=hash&SearchContentClassID=31"><span style="color: #0600FF;">hash</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #dd0000;">'parent_node_id'</span>, <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span> &nbsp; <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=if&SearchContentClassID=23"><span style="color: #0600FF;">if</span></a> <a href="https://ez.no/doc/content/advancedsearch?SearchText=gt&SearchContentClassID=31"><span style="color: #0600FF;">gt</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000bb;">$root_node_children</span><span style="color: #66cc66;">|</span>count,<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span> &lt;ul&gt; <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=foreach&SearchContentClassID=23"><span style="color: #0600FF;">foreach</span></a> <span style="color: #0000bb;">$root_node_children</span> as <span style="color: #0000bb;">$child</span><span style="color: #66cc66;">&#125;</span> &lt;li&gt; &lt;a href=<span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$child</span>.<span style="color: #006600;">url_alias</span><span style="color: #66cc66;">|</span>ezurl<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span>&gt;<span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$child</span>.<span style="color: #006600;">name</span><span style="color: #66cc66;">|</span>wash<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span>&lt;/a&gt; <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=if&SearchContentClassID=23"><span style="color: #0600FF;">if</span></a> <a href="https://ez.no/doc/content/advancedsearch?SearchText=or&SearchContentClassID=31"><span style="color: #0600FF;">or</span></a><span style="color: #66cc66;">&#40;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=eq&SearchContentClassID=31"><span style="color: #0600FF;">eq</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000bb;">$child</span>.<span style="color: #006600;">node_id</span>,<span style="color: #0000bb;">$module_result</span>.<span style="color: #006600;">node_id</span><span style="color: #66cc66;">&#41;</span>,<a href="https://ez.no/doc/content/advancedsearch?SearchText=eq&SearchContentClassID=31"><span style="color: #0600FF;">eq</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000bb;">$module_result</span>.<span style="color: #006600;">path</span>.1,<span style="color: #0000bb;">$child</span>.<span style="color: #006600;">node_id</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=set&SearchContentClassID=34"><span style="color: #0600FF;">set</span></a> <span style="color: #0000bb;">$second_level_children</span><span style="color: #66cc66;">=</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=fetch&SearchContentClassID=31"><span style="color: #0600FF;">fetch</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #dd0000;">'content'</span>,<span style="color: #dd0000;">'list'</span>,<a href="https://ez.no/doc/content/advancedsearch?SearchText=hash&SearchContentClassID=31"><span style="color: #0600FF;">hash</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #dd0000;">'parent_node_id'</span>, <span style="color: #0000bb;">$child</span>.<span style="color: #006600;">node_id</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=if&SearchContentClassID=23"><span style="color: #0600FF;">if</span></a> <a href="https://ez.no/doc/content/advancedsearch?SearchText=gt&SearchContentClassID=31"><span style="color: #0600FF;">gt</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000bb;">$second_level_children</span><span style="color: #66cc66;">|</span>count,<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span> &lt;ul&gt; <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=foreach&SearchContentClassID=23"><span style="color: #0600FF;">foreach</span></a> <span style="color: #0000bb;">$second_level_children</span> as <span style="color: #0000bb;">$child2</span><span style="color: #66cc66;">&#125;</span> &lt;li&gt;&lt;a href=<span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$child2</span>.<span style="color: #006600;">url_alias</span><span style="color: #66cc66;">|</span>ezurl<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span>&gt;<span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$child2</span>.<span style="color: #006600;">name</span><span style="color: #66cc66;">|</span>wash<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span>&lt;/a&gt;&lt;/li&gt; <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=foreach&SearchContentClassID=23"><span style="color: #0600FF;">foreach</span></a><span style="color: #66cc66;">&#125;</span> &lt;/ul&gt; <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=if&SearchContentClassID=23"><span style="color: #0600FF;">if</span></a><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=if&SearchContentClassID=23"><span style="color: #0600FF;">if</span></a><span style="color: #66cc66;">&#125;</span> &lt;li&gt; <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=foreach&SearchContentClassID=23"><span style="color: #0600FF;">foreach</span></a><span style="color: #66cc66;">&#125;</span> &lt;/ul&gt; <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=if&SearchContentClassID=23"><span style="color: #0600FF;">if</span></a><span style="color: #66cc66;">&#125;</span> &nbsp;</pre><p> First fetch the elements of the top level, foreach element check if it's the node that is being viewed or if it's one of its children's node. If so, show its children.<br />The code above has not been tested, but maybe would give you an idea on how to do it.</p><a name="eztoc918_3" id="eztoc918_3"></a><h2>References</h2> <ul> <li><a href="https://ez.no/community/forum/setup_design/dynamic_left_menu" target="_self">Dynamic Left Menu</a></li> </ul> Mon, 17 Aug 2009 07:25:01 GMT Template logic to fetch recently updated products https://ezpedia.org/snippet/template_logic_to_fetch_recently_updated_products https://ezpedia.org/snippet/template_logic_to_fetch_recently_updated_products <a name="eztoc24819_1" id="eztoc24819_1"></a><h2>Question</h2><p>How to fetch all objects of class 'product' recently published with object result limit of 3</p><a name="eztoc24819_2" id="eztoc24819_2"></a><h2>Answer</h2><p>Template file, ' <i>design/example/templates/toolbar/full/box_latest_products.tpl</i>'</p> <pre class="eztemplate" style="font-family:monospace;"><span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=def&SearchContentClassID=34"><span style="color: #0600FF;">def</span></a> <span style="color: #0000bb;">$products</span><span style="color: #66cc66;">=</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=fetch&SearchContentClassID=31"><span style="color: #0600FF;">fetch</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #dd0000;">'content'</span>, <span style="color: #dd0000;">'list'</span>, <a href="https://ez.no/doc/content/advancedsearch?SearchText=hash&SearchContentClassID=31"><span style="color: #0600FF;">hash</span></a><span style="color: #66cc66;">&#40;</span> <span style="color: #dd0000;">'parent_node_id'</span>, <span style="color: #cc66cc;">61</span>, <span style="color: #dd0000;">'sort_by'</span>, <a href="https://ez.no/doc/content/advancedsearch?SearchText=array&SearchContentClassID=31"><span style="color: #0600FF;">array</span></a><span style="color: #66cc66;">&#40;</span> <span style="color: #dd0000;">'published'</span>, <a href="https://ez.no/doc/content/advancedsearch?SearchText=false&SearchContentClassID=31"><span style="color: #0600FF;">false</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span>, <span style="color: #dd0000;">'limit'</span>, <span style="color: #cc66cc;">3</span>, <span style="color: #dd0000;">'class_filter_type'</span>, <span style="color: #dd0000;">'include'</span>, <span style="color: #dd0000;">'class_filter_array'</span>, <a href="https://ez.no/doc/content/advancedsearch?SearchText=array&SearchContentClassID=31"><span style="color: #0600FF;">array</span></a><span style="color: #66cc66;">&#40;</span> <span style="color: #dd0000;">'product'</span> <span style="color: #66cc66;">&#41;</span>, <span style="color: #dd0000;">'depth'</span>, <span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#125;</span> &lt;h2&gt;Latest Products&lt;/h2&gt; &lt;ul&gt; <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=foreach&SearchContentClassID=23"><span style="color: #0600FF;">foreach</span></a> <span style="color: #0000bb;">$products</span> as <span style="color: #0000bb;">$product</span><span style="color: #66cc66;">&#125;</span> <span style="color: #808080; font-style: italic;">{* $product.object|attribute(show,1) *}</span> &lt;li&gt;&lt;a href=<span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$product</span>.<span style="color: #006600;">url_alias</span><span style="color: #66cc66;">|</span>ezurl<span style="color: #66cc66;">&#125;</span>&gt;<span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$product</span>.<span style="color: #006600;">name</span><span style="color: #66cc66;">&#125;</span>&lt;/a&gt;&lt;br /&gt;<span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$product</span>.<span style="color: #006600;">object</span>.<span style="color: #006600;">modified</span><span style="color: #66cc66;">|</span>datetime<span style="color: #66cc66;">&#40;</span><span style="color: #dd0000;">'custom'</span>, <span style="color: #dd0000;">'%m/%d/%Y @ %G:%i'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span>&lt;/li&gt; <span style="color: #808080; font-style: italic;">{* {$product.count}</span> *} <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=foreach&SearchContentClassID=23"><span style="color: #0600FF;">foreach</span></a><span style="color: #66cc66;">&#125;</span> &lt;/ul&gt; <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=undef&SearchContentClassID=34"><span style="color: #0600FF;">undef</span></a><span style="color: #66cc66;">&#125;</span></pre> Mon, 17 Aug 2009 07:24:22 GMT Template logic to exclude a content object node from menus https://ezpedia.org/snippet/template_logic_to_exclude_a_content_object_node_from_menus https://ezpedia.org/snippet/template_logic_to_exclude_a_content_object_node_from_menus <p><i>Or, Looking for a way to hide a content?</i></p><a name="eztoc571_1" id="eztoc571_1"></a><h2>Problem</h2><p>I have many folders in the root eZ publish content tree (or elsewhere) which I do not want to be displayed in the menu.</p><p>Is there any way to add a folder to to eZ publish without it showing up in the top menus?</p><a name="eztoc571_2" id="eztoc571_2"></a><h2>Solution</h2><p>Using the eZ publish administrator, select Setup→Classes.</p><p>Edit your folder class and add checkbox called “Show in menu” (show_in_menu) By default checkbox is checked.</p><p>Then replace code in 'design/base/templates/menu/double_top.tpl' If you using double top menu.</p> <pre class="eztemplate" style="font-family:monospace;"><span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=section&SearchContentClassID=23"><span style="color: #0600FF;">section</span></a> <span style="color: #007700;">show</span><span style="color: #66cc66;">=</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=eq&SearchContentClassID=31"><span style="color: #0600FF;">eq</span></a><span style="color: #66cc66;">&#40;</span> <a href="https://ez.no/doc/content/advancedsearch?SearchText=sum&SearchContentClassID=31"><span style="color: #0600FF;">sum</span></a><span style="color: #66cc66;">&#40;</span> <span style="color: #0000bb;">$menu</span>.<span style="color: #006600;">index</span>, <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&#41;</span>, <span style="color: #0000bb;">$menuitems</span><span style="color: #66cc66;">|</span>count <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span> &lt;li class=&quot;last <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=eq&SearchContentClassID=31"><span style="color: #0600FF;">eq</span></a><span style="color: #66cc66;">&#40;</span> <span style="color: #0000bb;">$module_result</span>.<span style="color: #006600;">path</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">node_id</span>, <span style="color: #0000bb;">$menu</span>.<span style="color: #006600;">node_id</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span>choose<span style="color: #66cc66;">&#40;</span> <span style="color: #dd0000;">''</span>, <span style="color: #dd0000;">'selected'</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span>&quot;&gt;&lt;div class=&quot;spacing&quot;&gt;&lt;a href=<span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$menu</span>.<span style="color: #006600;">url_alias</span><span style="color: #66cc66;">|</span>ezurl<span style="color: #66cc66;">&#125;</span>&gt;<span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$menu</span>.<span style="color: #006600;">name</span><span style="color: #66cc66;">|</span>wash<span style="color: #66cc66;">&#125;</span>&lt;/a&gt;&lt;/div&gt;&lt;/li&gt; <span style="color: #66cc66;">&#123;</span>section-else<span style="color: #66cc66;">&#125;</span> &lt;li <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=eq&SearchContentClassID=31"><span style="color: #0600FF;">eq</span></a><span style="color: #66cc66;">&#40;</span> <span style="color: #0000bb;">$module_result</span>.<span style="color: #006600;">path</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">node_id</span>, <span style="color: #0000bb;">$menu</span>.<span style="color: #006600;">node_id</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span>choose<span style="color: #66cc66;">&#40;</span> <span style="color: #dd0000;">''</span>, <span style="color: #dd0000;">'class=&quot;selected&quot;'</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span>&gt;&lt;div class=&quot;spacing&quot;&gt;&lt;a href=<span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$menu</span>.<span style="color: #006600;">url_alias</span><span style="color: #66cc66;">|</span>ezurl<span style="color: #66cc66;">&#125;</span>&gt;<span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$menu</span>.<span style="color: #006600;">name</span><span style="color: #66cc66;">|</span>wash<span style="color: #66cc66;">&#125;</span>&lt;/a&gt;&lt;/div&gt;&lt;/li&gt; <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=section&SearchContentClassID=23"><span style="color: #0600FF;">section</span></a><span style="color: #66cc66;">&#125;</span></pre><p>With</p> <pre class="eztemplate" style="font-family:monospace;"><span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=section&SearchContentClassID=23"><span style="color: #0600FF;">section</span></a> <span style="color: #007700;">show</span><span style="color: #66cc66;">=</span><span style="color: #0000bb;">$menu</span>.<span style="color: #006600;">object</span>.<span style="color: #006600;">data_map</span>.<span style="color: #006600;">show_in_menu</span>.<span style="color: #006600;">data_int</span><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=section&SearchContentClassID=23"><span style="color: #0600FF;">section</span></a> <span style="color: #007700;">show</span><span style="color: #66cc66;">=</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=eq&SearchContentClassID=31"><span style="color: #0600FF;">eq</span></a><span style="color: #66cc66;">&#40;</span> <a href="https://ez.no/doc/content/advancedsearch?SearchText=sum&SearchContentClassID=31"><span style="color: #0600FF;">sum</span></a><span style="color: #66cc66;">&#40;</span> <span style="color: #0000bb;">$menu</span>.<span style="color: #006600;">index</span>, <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&#41;</span>, <span style="color: #0000bb;">$menuitems</span><span style="color: #66cc66;">|</span>count <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span> &lt;li class=&quot;last <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=eq&SearchContentClassID=31"><span style="color: #0600FF;">eq</span></a><span style="color: #66cc66;">&#40;</span> <span style="color: #0000bb;">$module_result</span>.<span style="color: #006600;">path</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">node_id</span>, <span style="color: #0000bb;">$menu</span>.<span style="color: #006600;">node_id</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span>choose<span style="color: #66cc66;">&#40;</span> <span style="color: #dd0000;">''</span>, <span style="color: #dd0000;">'selected'</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span>&quot;&gt;&lt;div class=&quot;spacing&quot;&gt;&lt;a href=<span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$menu</span>.<span style="color: #006600;">url_alias</span><span style="color: #66cc66;">|</span>ezurl<span style="color: #66cc66;">&#125;</span>&gt;<span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$menu</span>.<span style="color: #006600;">name</span><span style="color: #66cc66;">|</span>wash<span style="color: #66cc66;">&#125;</span>&lt;/a&gt;&lt;/div&gt;&lt;/li&gt; <span style="color: #66cc66;">&#123;</span>section-else<span style="color: #66cc66;">&#125;</span> &lt;li <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=eq&SearchContentClassID=31"><span style="color: #0600FF;">eq</span></a><span style="color: #66cc66;">&#40;</span> <span style="color: #0000bb;">$module_result</span>.<span style="color: #006600;">path</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">node_id</span>, <span style="color: #0000bb;">$menu</span>.<span style="color: #006600;">node_id</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span>choose<span style="color: #66cc66;">&#40;</span> <span style="color: #dd0000;">''</span>, <span style="color: #dd0000;">'class=&quot;selected&quot;'</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span>&gt;&lt;div class=&quot;spacing&quot;&gt;&lt;a href=<span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$menu</span>.<span style="color: #006600;">url_alias</span><span style="color: #66cc66;">|</span>ezurl<span style="color: #66cc66;">&#125;</span>&gt;<span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$menu</span>.<span style="color: #006600;">name</span><span style="color: #66cc66;">|</span>wash<span style="color: #66cc66;">&#125;</span>&lt;/a&gt;&lt;/div&gt;&lt;/li&gt; <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=section&SearchContentClassID=23"><span style="color: #0600FF;">section</span></a><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=section&SearchContentClassID=23"><span style="color: #0600FF;">section</span></a><span style="color: #66cc66;">&#125;</span></pre><p>If you usign design/base/templates/menu/flat_top menu replace</p> <pre class="eztemplate" style="font-family:monospace;"><span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=section&SearchContentClassID=23"><span style="color: #0600FF;">section</span></a> <span style="color: #007700;">show</span><span style="color: #66cc66;">=</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=eq&SearchContentClassID=31"><span style="color: #0600FF;">eq</span></a><span style="color: #66cc66;">&#40;</span> <a href="https://ez.no/doc/content/advancedsearch?SearchText=sum&SearchContentClassID=31"><span style="color: #0600FF;">sum</span></a><span style="color: #66cc66;">&#40;</span> <span style="color: #0000bb;">$menu</span>.<span style="color: #006600;">index</span>, <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&#41;</span>, <span style="color: #0000bb;">$menuitems</span><span style="color: #66cc66;">|</span>count <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span> &lt;li class=&quot;last <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=eq&SearchContentClassID=31"><span style="color: #0600FF;">eq</span></a><span style="color: #66cc66;">&#40;</span> <span style="color: #0000bb;">$module_result</span>.<span style="color: #006600;">path</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">node_id</span>, <span style="color: #0000bb;">$menu</span>.<span style="color: #006600;">node_id</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span>choose<span style="color: #66cc66;">&#40;</span> <span style="color: #dd0000;">''</span>, <span style="color: #dd0000;">'selected'</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span>&quot;&gt;&lt;div class=&quot;spacing&quot;&gt;&lt;a href=<span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$menu</span>.<span style="color: #006600;">url_alias</span><span style="color: #66cc66;">|</span>ezurl<span style="color: #66cc66;">&#125;</span>&gt;<span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$menu</span>.<span style="color: #006600;">name</span><span style="color: #66cc66;">|</span>wash<span style="color: #66cc66;">&#125;</span>&lt;/a&gt;&lt;/div&gt;&lt;/li&gt; <span style="color: #66cc66;">&#123;</span>section-else<span style="color: #66cc66;">&#125;</span> &lt;li <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=eq&SearchContentClassID=31"><span style="color: #0600FF;">eq</span></a><span style="color: #66cc66;">&#40;</span> <span style="color: #0000bb;">$module_result</span>.<span style="color: #006600;">path</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">node_id</span>, <span style="color: #0000bb;">$menu</span>.<span style="color: #006600;">node_id</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span>choose<span style="color: #66cc66;">&#40;</span> <span style="color: #dd0000;">''</span>, <span style="color: #dd0000;">'class=&quot;selected&quot;'</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span>&gt;&lt;div class=&quot;spacing&quot;&gt;&lt;a href=<span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$menu</span>.<span style="color: #006600;">url_alias</span><span style="color: #66cc66;">|</span>ezurl<span style="color: #66cc66;">&#125;</span>&gt;<span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$menu</span>.<span style="color: #006600;">name</span><span style="color: #66cc66;">|</span>wash<span style="color: #66cc66;">&#125;</span>&lt;/a&gt;&lt;/div&gt;&lt;/li&gt; <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=section&SearchContentClassID=23"><span style="color: #0600FF;">section</span></a><span style="color: #66cc66;">&#125;</span></pre><p>With</p> <pre class="eztemplate" style="font-family:monospace;"><span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=section&SearchContentClassID=23"><span style="color: #0600FF;">section</span></a> <span style="color: #007700;">show</span><span style="color: #66cc66;">=</span><span style="color: #0000bb;">$menu</span>.<span style="color: #006600;">object</span>.<span style="color: #006600;">data_map</span>.<span style="color: #006600;">show_in_menu</span>.<span style="color: #006600;">data_int</span><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=section&SearchContentClassID=23"><span style="color: #0600FF;">section</span></a> <span style="color: #007700;">show</span><span style="color: #66cc66;">=</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=eq&SearchContentClassID=31"><span style="color: #0600FF;">eq</span></a><span style="color: #66cc66;">&#40;</span> <a href="https://ez.no/doc/content/advancedsearch?SearchText=sum&SearchContentClassID=31"><span style="color: #0600FF;">sum</span></a><span style="color: #66cc66;">&#40;</span> <span style="color: #0000bb;">$menu</span>.<span style="color: #006600;">index</span>, <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&#41;</span>, <span style="color: #0000bb;">$menuitems</span><span style="color: #66cc66;">|</span>count <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span> &lt;li class=&quot;last <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=eq&SearchContentClassID=31"><span style="color: #0600FF;">eq</span></a><span style="color: #66cc66;">&#40;</span> <span style="color: #0000bb;">$module_result</span>.<span style="color: #006600;">path</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">node_id</span>, <span style="color: #0000bb;">$menu</span>.<span style="color: #006600;">node_id</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span>choose<span style="color: #66cc66;">&#40;</span> <span style="color: #dd0000;">''</span>, <span style="color: #dd0000;">'selected'</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span>&quot;&gt;&lt;div class=&quot;spacing&quot;&gt;&lt;a href=<span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$menu</span>.<span style="color: #006600;">url_alias</span><span style="color: #66cc66;">|</span>ezurl<span style="color: #66cc66;">&#125;</span>&gt;<span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$menu</span>.<span style="color: #006600;">name</span><span style="color: #66cc66;">|</span>wash<span style="color: #66cc66;">&#125;</span>&lt;/a&gt;&lt;/div&gt;&lt;/li&gt; <span style="color: #66cc66;">&#123;</span>section-else<span style="color: #66cc66;">&#125;</span> &lt;li <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=eq&SearchContentClassID=31"><span style="color: #0600FF;">eq</span></a><span style="color: #66cc66;">&#40;</span> <span style="color: #0000bb;">$module_result</span>.<span style="color: #006600;">path</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">node_id</span>, <span style="color: #0000bb;">$menu</span>.<span style="color: #006600;">node_id</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span>choose<span style="color: #66cc66;">&#40;</span> <span style="color: #dd0000;">''</span>, <span style="color: #dd0000;">'class=&quot;selected&quot;'</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span>&gt;&lt;div class=&quot;spacing&quot;&gt;&lt;a href=<span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$menu</span>.<span style="color: #006600;">url_alias</span><span style="color: #66cc66;">|</span>ezurl<span style="color: #66cc66;">&#125;</span>&gt;<span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$menu</span>.<span style="color: #006600;">name</span><span style="color: #66cc66;">|</span>wash<span style="color: #66cc66;">&#125;</span>&lt;/a&gt;&lt;/div&gt;&lt;/li&gt; <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=section&SearchContentClassID=23"><span style="color: #0600FF;">section</span></a><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=section&SearchContentClassID=23"><span style="color: #0600FF;">section</span></a><span style="color: #66cc66;">&#125;</span></pre><p>If show_in_menu flag is set to true (checked) item is show in menu.</p><p>Special thanks to participants: Negin Javadi, Gabriel Ambuehl, Lukasz Serwatka</p><a name="eztoc571_2_1" id="eztoc571_2_1"></a><h3>References</h3> <ul> <li><a href="https://ez.no/community/forum/setup_design/looking_for_a_way_to_hide_a_content#msg69407" target="_self">Looking for a way to hide a content</a></li> </ul> Mon, 17 Aug 2009 07:22:19 GMT Template logic to display fetched parent content object name https://ezpedia.org/snippet/template_logic_to_display_fetched_parent_content_object_name https://ezpedia.org/snippet/template_logic_to_display_fetched_parent_content_object_name <a name="eztoc758_1" id="eztoc758_1"></a><h2>Problem</h2><p>Is it possible to fetch the name of a parent folder?</p><a name="eztoc758_2" id="eztoc758_2"></a><h2>Solution</h2><p>I did this just today, does anyone have some ideas on how i could improve this soluton?</p><p>The solution I used was a second fetch to get the current item’s parrent name (in the main fetch’s loop).</p><a name="eztoc758_2_1" id="eztoc758_2_1"></a><h3>Abreviated </h3> <pre class="eztemplate" style="font-family:monospace;"><span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=set&SearchContentClassID=34"><span style="color: #0600FF;">set</span></a> <span style="color: #007700;">parent_id</span><span style="color: #66cc66;">=</span><span style="color: #0000bb;">$cnews</span>.<span style="color: #006600;">parent_node_id</span><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=set&SearchContentClassID=34"><span style="color: #0600FF;">set</span></a> <span style="color: #007700;">parent</span><span style="color: #66cc66;">=</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=fetch&SearchContentClassID=31"><span style="color: #0600FF;">fetch</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #dd0000;">'content'</span>,<span style="color: #dd0000;">'node'</span>, <a href="https://ez.no/doc/content/advancedsearch?SearchText=hash&SearchContentClassID=31"><span style="color: #0600FF;">hash</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #dd0000;">'node_id'</span>, <span style="color: #0000bb;">$parent_id</span> , limit, <span style="color: #cc66cc;">1</span> , sort_by, <a href="https://ez.no/doc/content/advancedsearch?SearchText=array&SearchContentClassID=31"><span style="color: #0600FF;">array</span></a><span style="color: #66cc66;">&#40;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=array&SearchContentClassID=31"><span style="color: #0600FF;">array</span></a><span style="color: #66cc66;">&#40;</span>published, <a href="https://ez.no/doc/content/advancedsearch?SearchText=false&SearchContentClassID=31"><span style="color: #0600FF;">false</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=set&SearchContentClassID=34"><span style="color: #0600FF;">set</span></a> <span style="color: #007700;">news_category</span><span style="color: #66cc66;">=</span><span style="color: #0000bb;">$parent</span>.<span style="color: #006600;">name</span><span style="color: #66cc66;">&#125;</span> &nbsp;</pre><a name="eztoc758_2_2" id="eztoc758_2_2"></a><h3>Complete</h3> <pre class="eztemplate" style="font-family:monospace;">New Objects: &lt;br /&gt; &lt;span style=&quot;font-size: 11px;&quot;&gt; <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=set&SearchContentClassID=34"><span style="color: #0600FF;">set</span></a> <span style="color: #007700;">news_id</span><span style="color: #66cc66;">=</span><span style="color: #cc66cc;">344</span><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=set&SearchContentClassID=34"><span style="color: #0600FF;">set</span></a> <span style="color: #007700;">news_limit</span><span style="color: #66cc66;">=</span><span style="color: #cc66cc;">4</span><span style="color: #66cc66;">&#125;</span> &nbsp; <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=let&SearchContentClassID=34"><span style="color: #0600FF;">let</span></a> <span style="color: #007700;">recent</span><span style="color: #66cc66;">=</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=fetch&SearchContentClassID=31"><span style="color: #0600FF;">fetch</span></a><span style="color: #66cc66;">&#40;</span> content, tree, <a href="https://ez.no/doc/content/advancedsearch?SearchText=hash&SearchContentClassID=31"><span style="color: #0600FF;">hash</span></a><span style="color: #66cc66;">&#40;</span> parent_node_id, <span style="color: #0000bb;">$news_id</span>, limit, <span style="color: #0000bb;">$news_limit</span>, <span style="color: #dd0000;">'class_filter_type'</span>, <span style="color: #dd0000;">'include'</span>, <span style="color: #dd0000;">'class_filter_array'</span>, <a href="https://ez.no/doc/content/advancedsearch?SearchText=array&SearchContentClassID=31"><span style="color: #0600FF;">array</span></a><span style="color: #66cc66;">&#40;</span> <span style="color: #dd0000;">'article'</span> <span style="color: #66cc66;">&#41;</span> , sort_by, <a href="https://ez.no/doc/content/advancedsearch?SearchText=array&SearchContentClassID=31"><span style="color: #0600FF;">array</span></a><span style="color: #66cc66;">&#40;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=array&SearchContentClassID=31"><span style="color: #0600FF;">array</span></a><span style="color: #66cc66;">&#40;</span>published, <a href="https://ez.no/doc/content/advancedsearch?SearchText=false&SearchContentClassID=31"><span style="color: #0600FF;">false</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=section&SearchContentClassID=23"><span style="color: #0600FF;">section</span></a> <span style="color: #007700;">show</span><span style="color: #66cc66;">=</span><span style="color: #0000bb;">$recent</span><span style="color: #66cc66;">|</span>count<span style="color: #66cc66;">|</span>gt<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=section&SearchContentClassID=23"><span style="color: #0600FF;">section</span></a> <span style="color: #007700;">var</span><span style="color: #66cc66;">=</span>cnews <span style="color: #007700;">loop</span><span style="color: #66cc66;">=</span><span style="color: #0000bb;">$recent</span><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=set&SearchContentClassID=34"><span style="color: #0600FF;">set</span></a> <span style="color: #007700;">news_title</span><span style="color: #66cc66;">=</span><span style="color: #0000bb;">$cnews</span>.<span style="color: #006600;">name</span><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=set&SearchContentClassID=34"><span style="color: #0600FF;">set</span></a> <span style="color: #007700;">news_intro</span><span style="color: #66cc66;">=</span><span style="color: #0000bb;">$cnews</span>.<span style="color: #006600;">data_map</span>.<span style="color: #006600;">intro</span>.<span style="color: #006600;">data_text</span><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=set&SearchContentClassID=34"><span style="color: #0600FF;">set</span></a> <span style="color: #007700;">news_date_formated</span><span style="color: #66cc66;">=</span><span style="color: #0000bb;">$cnews</span>.<span style="color: #006600;">object</span>.<span style="color: #006600;">current</span>.<span style="color: #006600;">created</span> <span style="color: #66cc66;">|</span>datetime<span style="color: #66cc66;">&#40;</span> <span style="color: #dd0000;">'custom'</span>, <span style="color: #dd0000;">'%m/%d/%Y @ %h:%i'</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span> &nbsp; <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=set&SearchContentClassID=34"><span style="color: #0600FF;">set</span></a> <span style="color: #007700;">parent_id</span><span style="color: #66cc66;">=</span><span style="color: #0000bb;">$cnews</span>.<span style="color: #006600;">parent_node_id</span><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=set&SearchContentClassID=34"><span style="color: #0600FF;">set</span></a> <span style="color: #007700;">parent</span><span style="color: #66cc66;">=</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=fetch&SearchContentClassID=31"><span style="color: #0600FF;">fetch</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #dd0000;">'content'</span>,<span style="color: #dd0000;">'node'</span>, <a href="https://ez.no/doc/content/advancedsearch?SearchText=hash&SearchContentClassID=31"><span style="color: #0600FF;">hash</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #dd0000;">'node_id'</span>, <span style="color: #0000bb;">$parent_id</span> , limit, <span style="color: #cc66cc;">1</span> , sort_by, <a href="https://ez.no/doc/content/advancedsearch?SearchText=array&SearchContentClassID=31"><span style="color: #0600FF;">array</span></a><span style="color: #66cc66;">&#40;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=array&SearchContentClassID=31"><span style="color: #0600FF;">array</span></a><span style="color: #66cc66;">&#40;</span>published, <a href="https://ez.no/doc/content/advancedsearch?SearchText=false&SearchContentClassID=31"><span style="color: #0600FF;">false</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=set&SearchContentClassID=34"><span style="color: #0600FF;">set</span></a> <span style="color: #007700;">news_category</span><span style="color: #66cc66;">=</span><span style="color: #0000bb;">$parent</span>.<span style="color: #006600;">name</span><span style="color: #66cc66;">&#125;</span> &lt;div style=&quot;padding-top: 2px; padding-bottom: 8px;&quot;&gt;&lt;span&gt;&lt;a href=&quot;<span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$cnews</span>.<span style="color: #006600;">url_alias</span><span style="color: #66cc66;">&#125;</span>&quot; style=&quot;color:#004A84;&quot;&gt;<span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$news_title</span><span style="color: #66cc66;">|</span>shorten<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">348</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span>&lt;/a&gt;&lt;/span&gt;&lt;div align=&quot;right&quot;&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;Added to Category: <span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$news_category</span><span style="color: #66cc66;">&#125;</span>&lt;br /&gt;&lt;span style=&quot;font-size: 10px; color: grey;&quot;&gt;Released: <span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$news_date_formated</span><span style="color: #66cc66;">&#125;</span>&lt;/span&gt;&lt;/div&gt;&lt;/div&gt; <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=section&SearchContentClassID=23"><span style="color: #0600FF;">section</span></a><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=section&SearchContentClassID=23"><span style="color: #0600FF;">section</span></a><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=let&SearchContentClassID=34"><span style="color: #0600FF;">let</span></a><span style="color: #66cc66;">&#125;</span> &lt;/span&gt; &nbsp;</pre><a name="eztoc758_2_3" id="eztoc758_2_3"></a><h3>Participants</h3> <ul> <li>haavard h, J-A Eberhard, and of course the inevitable kracker</li> </ul> <a name="eztoc758_2_4" id="eztoc758_2_4"></a><h3>References</h3> <ul> <li><a href="https://ez.no/community/forum/general/name_of_a_parent" title="https://ez.no/community/forum/general/name_of_a_parent" target="_blank"> Is it possible to fetch the name of a parent folder?</a></li> </ul> Mon, 17 Aug 2009 07:20:45 GMT Template logic to fetch and group results by letter https://ezpedia.org/snippet/template_logic_to_fetch_and_group_results_by_letter https://ezpedia.org/snippet/template_logic_to_fetch_and_group_results_by_letter <a name="eztoc937_1" id="eztoc937_1"></a><h2>Question</h2><p>I am using fetch and need to use a view_parameter to filter the data ...</p><p><i>Sort.</i> I need to sort the items by first letter (a , b , c , d ...)</p><p><i>Group.</i> I need the items 'grouped' by letter</p><p>&lt;awormus&gt; and I didn't want to do a &quot;first letter&quot; attribute which would have been silly :)</p><a name="eztoc937_2" id="eztoc937_2"></a><h2>Answer</h2><p>Try using the <a href="/es/ez/alphabet" target="_self">alphabet</a> navigator features added in 3.9</p><p>I prefer this solution these days rather than more custom code.</p><a name="eztoc937_3" id="eztoc937_3"></a><h2>Another Answer</h2><p><a href="https://ez.no/doc/ez_publish/technical_manual/3_8/reference/modules/content/fetch_functions/keyword" target="_self">https://ez.no/doc/ez_publish/technical_manual/3_8/reference/modules/content/fetch_functions/keyword</a></p><a name="eztoc937_4" id="eztoc937_4"></a><h2>Yet Another Answer</h2> <pre class="eztemplate" style="font-family:monospace;"><span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=def&SearchContentClassID=34"><span style="color: #0600FF;">def</span></a> <span style="color: #0000bb;">$items</span> <span style="color: #66cc66;">=</span> <a href="https://ez.no/doc/content/advancedsearch?SearchText=fetch&SearchContentClassID=31"><span style="color: #0600FF;">fetch</span></a><span style="color: #66cc66;">&#40;</span> <span style="color: #dd0000;">'content'</span>, <span style="color: #dd0000;">'list'</span>, <a href="https://ez.no/doc/content/advancedsearch?SearchText=hash&SearchContentClassID=31"><span style="color: #0600FF;">hash</span></a><span style="color: #66cc66;">&#40;</span> parent_node_id, <span style="color: #0000bb;">$node</span>.<span style="color: #006600;">node_id</span>,<span style="color: #dd0000;">'sort_by'</span>, <a href="https://ez.no/doc/content/advancedsearch?SearchText=array&SearchContentClassID=31"><span style="color: #0600FF;">array</span></a><span style="color: #66cc66;">&#40;</span> <span style="color: #dd0000;">'name'</span>, <a href="https://ez.no/doc/content/advancedsearch?SearchText=true&SearchContentClassID=31"><span style="color: #0600FF;">true</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=foreach&SearchContentClassID=23"><span style="color: #0600FF;">foreach</span></a> <span style="color: #0000bb;">$items</span> as <span style="color: #0000bb;">$item</span><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=if&SearchContentClassID=23"><span style="color: #0600FF;">if</span></a> <span style="color: #0000bb;">$item</span>.<span style="color: #006600;">data_map</span>.<span style="color: #006600;">term_term</span>.<span style="color: #006600;">value</span><span style="color: #66cc66;">|</span>begins_with<span style="color: #66cc66;">&#40;</span><span style="color: #0000bb;">$view_parameters</span>.<span style="color: #006600;">view</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span> &lt;div&gt; &lt;span class=&quot;subheaders&quot;&gt;<span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$item</span>.<span style="color: #006600;">data_map</span>.<span style="color: #006600;">term_term</span>.<span style="color: #006600;">value</span><span style="color: #66cc66;">&#125;</span>: &lt;/span&gt; &lt;span class=&quot;content&quot;&gt; <span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$foo</span>.<span style="color: #006600;">data_map</span>.<span style="color: #006600;">term_description</span>.<span style="color: #006600;">value</span><span style="color: #66cc66;">&#125;</span> &lt;/span&gt; &lt;/div&gt; <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=if&SearchContentClassID=23"><span style="color: #0600FF;">if</span></a><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=foreach&SearchContentClassID=23"><span style="color: #0600FF;">foreach</span></a><span style="color: #66cc66;">&#125;</span></pre> Mon, 17 Aug 2009 07:17:05 GMT Template logic to provide users with printable search layout https://ezpedia.org/snippet/template_logic_to_provide_users_with_printable_search_layout https://ezpedia.org/snippet/template_logic_to_provide_users_with_printable_search_layout <a name="eztoc4264_1" id="eztoc4264_1"></a><h2><b>Background</b></h2><p>I was recently updating an eZ publish search implementation. I noticed that the site design used a print icon in it's page layout, yet sadly it was hard coded to only work on page views which displayed node content. (statically linked to for content view full + node_id).</p><p>On page views using the search (displaying results) the printable link naturally did not function and would link to an incomplete url. Leading me to sneaking implementing alternate printable views (other than 'view') like advanced search (results). </p><p>Yet I ran into a problem of how to do this the <i>'eZ'</i> way, this must have been done before (dynamic printable link for alternate module views :\)</p><a name="eztoc4264_2" id="eztoc4264_2"></a><h2><b>The Question</b></h2><p>How to detect in $module_result or other template variable when using the '/content/advancedsearch/' module as apposed to 'view'.</p><p>Using the above solution, then how would you create a print this page link (#1) which passes the search url parameters to a printer friendly template layout and navigator.</p><a name="eztoc4264_3" id="eztoc4264_3"></a><h2>The first answer found</h2><p>On ez.no and in the demo the printer version link made no sense on search, only printing without results where possible. </p><p>Change the code in page_layout_section_xxx.tpl or where else into:</p> <pre class="eztemplate" style="font-family:monospace;"><span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=section&SearchContentClassID=23"><span style="color: #0600FF;">section</span></a> <span style="color: #007700;">show</span><span style="color: #66cc66;">=</span><span style="color: #0000bb;">$enable_print</span><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=section&SearchContentClassID=23"><span style="color: #0600FF;">section</span></a> <span style="color: #007700;">show</span><span style="color: #66cc66;">=</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=is_set&SearchContentClassID=31"><span style="color: #0600FF;">is_set</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000bb;">$search_text_enc</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=section&SearchContentClassID=23"><span style="color: #0600FF;">section</span></a> <span style="color: #007700;">show</span><span style="color: #66cc66;">=</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=is_set&SearchContentClassID=31"><span style="color: #0600FF;">is_set</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000bb;">$search_contentclass_id</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span> &lt;a href=<span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=concat&SearchContentClassID=31"><span style="color: #0600FF;">concat</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #dd0000;">'layout/set/print/'</span>,<span style="color: #0000bb;">$site</span>.<span style="color: #006600;">uri</span>.<span style="color: #006600;">tail</span>,<span style="color: #dd0000;">'?SearchText='</span>,<span style="color: #0000bb;">$search_text_enc</span>,<span style="color: #dd0000;">'&amp;SearchContentClassAttributeID='</span>,<span style="color: #0000bb;">$search_contentclass_id</span>,<span style="color: #dd0000;">'&amp;SearchSectionID='</span>,<span style="color: #0000bb;">$search_section_id</span>,<span style="color: #dd0000;">'&amp;SearchDate='</span>,<span style="color: #0000bb;">$search_date</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span>ezurl<span style="color: #66cc66;">&#125;</span> class=&quot;path&quot;&gt;<span style="color: #66cc66;">&#123;</span><span style="color: #dd0000;">'Printable version'</span><span style="color: #66cc66;">|</span>i18n<span style="color: #66cc66;">&#40;</span><span style="color: #dd0000;">'design/standard/layout'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span>&lt;/a&gt; <span style="color: #66cc66;">&#123;</span>section-else<span style="color: #66cc66;">&#125;</span> &lt;a href=<span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=concat&SearchContentClassID=31"><span style="color: #0600FF;">concat</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #dd0000;">'layout/set/print/'</span>,<span style="color: #0000bb;">$site</span>.<span style="color: #006600;">uri</span>.<span style="color: #006600;">tail</span>,<span style="color: #dd0000;">'?SearchText='</span>,<span style="color: #0000bb;">$search_text_enc</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span>ezurl<span style="color: #66cc66;">&#125;</span> class=&quot;path&quot;&gt;<span style="color: #66cc66;">&#123;</span><span style="color: #dd0000;">'Printable version'</span><span style="color: #66cc66;">|</span>i18n<span style="color: #66cc66;">&#40;</span><span style="color: #dd0000;">'design/standard/layout'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span>&lt;/a&gt; <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=section&SearchContentClassID=23"><span style="color: #0600FF;">section</span></a><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span>section-else<span style="color: #66cc66;">&#125;</span> &lt;a href=<span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=concat&SearchContentClassID=31"><span style="color: #0600FF;">concat</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #dd0000;">&quot;layout/set/print/&quot;</span>,<span style="color: #0000bb;">$site</span>.<span style="color: #006600;">uri</span>.<span style="color: #006600;">tail</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span>ezurl<span style="color: #66cc66;">&#125;</span> class=&quot;path&quot;&gt;<span style="color: #66cc66;">&#123;</span><span style="color: #dd0000;">'Printable version'</span><span style="color: #66cc66;">|</span>i18n<span style="color: #66cc66;">&#40;</span><span style="color: #dd0000;">'design/standard/layout'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span>&lt;/a&gt; <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=section&SearchContentClassID=23"><span style="color: #0600FF;">section</span></a><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=section&SearchContentClassID=23"><span style="color: #0600FF;">section</span></a><span style="color: #66cc66;">&#125;</span></pre><a name="eztoc4264_3_1" id="eztoc4264_3_1"></a><h3>A second answer</h3><p>Do the print with only a css (media=print). It works fine.</p><a name="eztoc4264_4" id="eztoc4264_4"></a><h2>References</h2><p>Forum: <a href="https://ez.no/community/forum/developer/printable_search_in_ez" target="_self">Printable Search in eZ</a> </p> Mon, 17 Aug 2009 07:10:50 GMT Template logic to add edit button into your custom user siteaccess design https://ezpedia.org/snippet/template_logic_to_add_edit_button_into_your_custom_user_siteaccess_design https://ezpedia.org/snippet/template_logic_to_add_edit_button_into_your_custom_user_siteaccess_design <p>From: Rappy and Zurgutt </p><p>Date: 11-16-2005 07:52:30 </p><p>Question (Rappy): Anyhow, can someone point me to the place where I can read about how to make an edit-button on the site (that is visible when a user with the correct roles are logged in) </p><p>Answere (zrg): you have come to the master :) hang on ill give codesnippet. It has the added possibility of limiting number of objects in each class for given usergroup. Its nice for like mini hosting-plan, “you get to make 5 forums, if you want more, $$”. Unfortunately there seems not to be function to CHECK for existence of ini value, so code below will spam error log.. im open to suggestions. Needless to say it only removes creation choice, no actual access security.. </p><p>This goes to ini in my case to limit Guest users (group 12) to only one blog each (blog container id 31) </p> <pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #666666; font-style: italic;">/* #?ini charset=&quot;utf8&quot;? &nbsp; [PerGroupClassLimits] ClassLimit_12_31=1 &nbsp; */</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre><p>eZ template source code</p> <pre class="eztemplate" style="font-family:monospace;"><span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=let&SearchContentClassID=34"><span style="color: #0600FF;">let</span></a> <span style="color: #007700;">node</span><span style="color: #66cc66;">=</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=fetch&SearchContentClassID=31"><span style="color: #0600FF;">fetch</span></a><span style="color: #66cc66;">&#40;</span> content, node, <a href="https://ez.no/doc/content/advancedsearch?SearchText=hash&SearchContentClassID=31"><span style="color: #0600FF;">hash</span></a><span style="color: #66cc66;">&#40;</span> node_id, <span style="color: #0000bb;">$module_result</span>.<span style="color: #006600;">node_id</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #007700;">current_user</span><span style="color: #66cc66;">=</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=fetch&SearchContentClassID=31"><span style="color: #0600FF;">fetch</span></a><span style="color: #66cc66;">&#40;</span> user, current_user <span style="color: #66cc66;">&#41;</span> <span style="color: #007700;">user_group_id</span><span style="color: #66cc66;">=</span><span style="color: #0000bb;">$current_user</span>.<span style="color: #006600;">contentobject</span>.<span style="color: #006600;">main_parent_node_id</span> <span style="color: #66cc66;">&#125;</span> &lt;div id=&quot;quickedit&quot;&gt; &lt;div class=&quot;buttonblock&quot;&gt; &lt;form method=&quot;post&quot; action=<span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=concat&SearchContentClassID=31"><span style="color: #0600FF;">concat</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #dd0000;">&quot;/content/action/&quot;</span>, <span style="color: #0000bb;">$node</span>.<span style="color: #006600;">object</span>.<span style="color: #006600;">id</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">|</span>ezurl<span style="color: #66cc66;">&#125;</span>&gt; <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=section&SearchContentClassID=23"><span style="color: #0600FF;">section</span></a> <span style="color: #007700;">show</span><span style="color: #66cc66;">=</span><span style="color: #0000bb;">$node</span>.<span style="color: #006600;">object</span>.<span style="color: #006600;">can_edit</span><span style="color: #66cc66;">&#125;</span> &lt;input type=&quot;hidden&quot; name=&quot;ContentNodeID&quot; value=&quot;<span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$node</span>.<span style="color: #006600;">object</span>.<span style="color: #006600;">main_node_id</span><span style="color: #66cc66;">&#125;</span>&quot; /&gt; &lt;input type=&quot;hidden&quot; name=&quot;ContentObjectID&quot; value=&quot;<span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$node</span>.<span style="color: #006600;">object</span>.<span style="color: #006600;">id</span><span style="color: #66cc66;">&#125;</span>&quot; /&gt; &lt;input class=&quot;button&quot; type=&quot;submit&quot; name=&quot;EditButton&quot; value=&quot;<span style="color: #66cc66;">&#123;</span><span style="color: #dd0000;">'Edit'</span><span style="color: #66cc66;">|</span>i18n<span style="color: #66cc66;">&#40;</span><span style="color: #dd0000;">'design/standard/node/view'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span>&quot; /&gt; &lt;input class=&quot;button&quot; type=&quot;submit&quot; name=&quot;ActionRemove&quot; value=&quot;<span style="color: #66cc66;">&#123;</span><span style="color: #dd0000;">'Remove'</span><span style="color: #66cc66;">|</span>i18n<span style="color: #66cc66;">&#40;</span><span style="color: #dd0000;">'design/standard/node/view'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span>&quot; /&gt; &lt;br&gt; <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=section&SearchContentClassID=23"><span style="color: #0600FF;">section</span></a><span style="color: #66cc66;">&#125;</span> &nbsp; <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=def&SearchContentClassID=34"><span style="color: #0600FF;">def</span></a> <span style="color: #0000bb;">$limited_list</span><span style="color: #66cc66;">=</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=array&SearchContentClassID=31"><span style="color: #0600FF;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=section&SearchContentClassID=23"><span style="color: #0600FF;">section</span></a> <span style="color: #007700;">var</span><span style="color: #66cc66;">=</span>class <span style="color: #007700;">loop</span><span style="color: #66cc66;">=</span><span style="color: #0000bb;">$node</span>.<span style="color: #006600;">object</span>.<span style="color: #006600;">can_create_class_list</span><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=def&SearchContentClassID=34"><span style="color: #0600FF;">def</span></a> <span style="color: #0000bb;">$limit</span><span style="color: #66cc66;">=</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=ezini&SearchContentClassID=31"><span style="color: #0600FF;">ezini</span></a><span style="color: #66cc66;">&#40;</span> <span style="color: #dd0000;">'PerGroupClassLimits'</span>, <a href="https://ez.no/doc/content/advancedsearch?SearchText=concat&SearchContentClassID=31"><span style="color: #0600FF;">concat</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #dd0000;">'ClassLimit_'</span>, <span style="color: #0000bb;">$user_group_id</span>, <span style="color: #dd0000;">'_'</span>, <span style="color: #0000bb;">$class</span>.<span style="color: #006600;">id</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #dd0000;">'limits.ini'</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=if&SearchContentClassID=23"><span style="color: #0600FF;">if</span></a> <a href="https://ez.no/doc/content/advancedsearch?SearchText=not&SearchContentClassID=31"><span style="color: #0600FF;">not</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000bb;">$limit</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=set&SearchContentClassID=34"><span style="color: #0600FF;">set</span></a> <span style="color: #0000bb;">$limited_list</span><span style="color: #66cc66;">=</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=merge&SearchContentClassID=31"><span style="color: #0600FF;">merge</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000bb;">$limited_list</span>, <a href="https://ez.no/doc/content/advancedsearch?SearchText=array&SearchContentClassID=31"><span style="color: #0600FF;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000bb;">$class</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span>else<span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=def&SearchContentClassID=34"><span style="color: #0600FF;">def</span></a> <span style="color: #0000bb;">$existing</span><span style="color: #66cc66;">=</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=fetch&SearchContentClassID=31"><span style="color: #0600FF;">fetch</span></a><span style="color: #66cc66;">&#40;</span> <span style="color: #dd0000;">'content'</span>, <span style="color: #dd0000;">'object_count_by_user_id'</span>, <a href="https://ez.no/doc/content/advancedsearch?SearchText=hash&SearchContentClassID=31"><span style="color: #0600FF;">hash</span></a><span style="color: #66cc66;">&#40;</span> <span style="color: #dd0000;">'class_id'</span>, <span style="color: #0000bb;">$class</span>.<span style="color: #006600;">id</span>, <span style="color: #dd0000;">'user_id'</span>, <span style="color: #0000bb;">$current_user</span>.<span style="color: #006600;">contentobject_id</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=if&SearchContentClassID=23"><span style="color: #0600FF;">if</span></a> <a href="https://ez.no/doc/content/advancedsearch?SearchText=gt&SearchContentClassID=31"><span style="color: #0600FF;">gt</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000bb;">$limit</span>, <span style="color: #0000bb;">$existing</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=set&SearchContentClassID=34"><span style="color: #0600FF;">set</span></a> <span style="color: #0000bb;">$limited_list</span><span style="color: #66cc66;">=</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=merge&SearchContentClassID=31"><span style="color: #0600FF;">merge</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000bb;">$limited_list</span>, <a href="https://ez.no/doc/content/advancedsearch?SearchText=array&SearchContentClassID=31"><span style="color: #0600FF;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000bb;">$class</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=if&SearchContentClassID=23"><span style="color: #0600FF;">if</span></a><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=if&SearchContentClassID=23"><span style="color: #0600FF;">if</span></a><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=section&SearchContentClassID=23"><span style="color: #0600FF;">section</span></a><span style="color: #66cc66;">&#125;</span> &nbsp; <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=section&SearchContentClassID=23"><span style="color: #0600FF;">section</span></a> <span style="color: #007700;">show</span><span style="color: #66cc66;">=</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=count&SearchContentClassID=31"><span style="color: #0600FF;">count</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000bb;">$limited_list</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span> &lt;br&gt; &lt;input type=&quot;hidden&quot; name=&quot;NodeID&quot; value=&quot;<span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$node</span>.<span style="color: #006600;">node_id</span><span style="color: #66cc66;">&#125;</span>&quot; /&gt; &lt;select name=&quot;ClassID&quot;&gt; <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=section&SearchContentClassID=23"><span style="color: #0600FF;">section</span></a> <span style="color: #007700;">var</span><span style="color: #66cc66;">=</span>class <span style="color: #007700;">loop</span><span style="color: #66cc66;">=</span><span style="color: #0000bb;">$limited_list</span><span style="color: #66cc66;">&#125;</span> &lt;option value=&quot;<span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$class</span>.<span style="color: #006600;">id</span><span style="color: #66cc66;">&#125;</span>&quot;&gt;<span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$class</span>.<span style="color: #006600;">name</span><span style="color: #66cc66;">|</span>wash<span style="color: #66cc66;">&#125;</span>&lt;/option&gt; <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=section&SearchContentClassID=23"><span style="color: #0600FF;">section</span></a><span style="color: #66cc66;">&#125;</span> &lt;/select&gt; &lt;input class=&quot;button&quot; type=&quot;submit&quot; name=&quot;NewButton&quot; value=&quot;<span style="color: #66cc66;">&#123;</span><span style="color: #dd0000;">'Create here'</span><span style="color: #66cc66;">|</span>i18n<span style="color: #66cc66;">&#40;</span><span style="color: #dd0000;">'design/standard/node/view'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span>&quot; /&gt; <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=section&SearchContentClassID=23"><span style="color: #0600FF;">section</span></a><span style="color: #66cc66;">&#125;</span> &lt;/form&gt; <span style="color: #808080; font-style: italic;">{** &lt;form method=&quot;post&quot; action={concat(&quot;/content/hide/&quot;, $node.node_id)|ezurl}</span>&gt; &lt;input class=&quot;button&quot; type=&quot;submit&quot; name=&quot;Hide&quot; value=&quot;Hide&quot; /&gt; &lt;/form&gt; **} &lt;/div&gt; &lt;/div&gt; <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=let&SearchContentClassID=34"><span style="color: #0600FF;">let</span></a><span style="color: #66cc66;">&#125;</span></pre> Mon, 17 Aug 2009 07:04:29 GMT Template logic to fetch and display content objects image attribute content https://ezpedia.org/snippet/template_logic_to_fetch_and_display_content_objects_image_attribute_content https://ezpedia.org/snippet/template_logic_to_fetch_and_display_content_objects_image_attribute_content <p>Submited via forums by Lukasz Serwatka</p><a name="eztoc762_1" id="eztoc762_1"></a><h2>Solution</h2><p>Template code which fetchs an image from my image gallery. The image is different depending on what node the user is currently viewing.</p> <pre class="eztemplate" style="font-family:monospace;"><span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=let&SearchContentClassID=34"><span style="color: #0600FF;">let</span></a> <span style="color: #007700;">myimage</span><span style="color: #66cc66;">=</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=fetch&SearchContentClassID=31"><span style="color: #0600FF;">fetch</span></a><span style="color: #66cc66;">&#40;</span> <span style="color: #dd0000;">'content'</span>, <span style="color: #dd0000;">'node'</span>, <a href="https://ez.no/doc/content/advancedsearch?SearchText=hash&SearchContentClassID=31"><span style="color: #0600FF;">hash</span></a><span style="color: #66cc66;">&#40;</span> <span style="color: #dd0000;">'node_id'</span>, <span style="color: #cc66cc;">123</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span> &nbsp; <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=attribute_view_gui&SearchContentClassID=34"><span style="color: #0600FF;">attribute_view_gui</span></a> <span style="color: #007700;">attribute</span><span style="color: #66cc66;">=</span><span style="color: #0000bb;">$myimage</span>.<span style="color: #006600;">object</span>.<span style="color: #006600;">data_map</span>.<a href="https://ez.no/doc/content/advancedsearch?SearchText=image&SearchContentClassID=31"><span style="color: #0600FF;">image</span></a><span style="color: #66cc66;">&#125;</span> &nbsp; <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=let&SearchContentClassID=34"><span style="color: #0600FF;">let</span></a><span style="color: #66cc66;">&#125;</span> &nbsp;</pre><a name="eztoc762_2" id="eztoc762_2"></a><h2>References</h2> <ul> <li><a href="https://www.ez.no/community/forum/setup_design/displaying_my_fetched_image#msg68903" title="https://www.ez.no/community/forum/setup_design/displaying_my_fetched_image#msg68903" target="_blank">Displaying my fetched image</a></li> </ul> Mon, 17 Aug 2009 07:02:45 GMT Template logic to fetch and display collected information content objects https://ezpedia.org/snippet/template_logic_to_fetch_and_display_collected_information_content_objects https://ezpedia.org/snippet/template_logic_to_fetch_and_display_collected_information_content_objects <a name="eztoc237959_1" id="eztoc237959_1"></a><h2>Solution</h2><p>This piece of template code iterating the already stored and collected information has only the purpose of demonstration.</p> <pre class="eztemplate" style="font-family:monospace;"><span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=def&SearchContentClassID=34"><span style="color: #0600FF;">def</span></a> <span style="color: #0000bb;">$collection</span><span style="color: #66cc66;">=</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=fetch&SearchContentClassID=31"><span style="color: #0600FF;">fetch</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #dd0000;">'content'</span>,<span style="color: #dd0000;">'collected_info_list'</span>, <a href="https://ez.no/doc/content/advancedsearch?SearchText=hash&SearchContentClassID=31"><span style="color: #0600FF;">hash</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #dd0000;">'object_id'</span>, <span style="color: #0000bb;">$obj</span>.<span style="color: #006600;">id</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=foreach&SearchContentClassID=23"><span style="color: #0600FF;">foreach</span></a> <span style="color: #0000bb;">$collection</span> as <span style="color: #0000bb;">$col</span><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$col</span>.<span style="color: #006600;">creator</span>.<span style="color: #006600;">contentobject</span>.<span style="color: #006600;">name</span><span style="color: #66cc66;">|</span>wash<span style="color: #66cc66;">&#125;</span> <span style="color: #808080; font-style: italic;">{* name of the user who stored something into the i.c. *}</span> <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=foreach&SearchContentClassID=23"><span style="color: #0600FF;">foreach</span></a> <span style="color: #0000bb;">$col</span>.<span style="color: #006600;">attributes</span> as <span style="color: #0000bb;">$colAttr</span><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$colAttr</span>.<span style="color: #006600;">contentclass_attribute_name</span><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=attribute_result_gui&SearchContentClassID=34"><span style="color: #0600FF;">attribute_result_gui</span></a> <span style="color: #007700;">view</span><span style="color: #66cc66;">=</span>info <span style="color: #007700;">attribute</span><span style="color: #66cc66;">=</span><span style="color: #0000bb;">$colAttr</span><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=foreach&SearchContentClassID=23"><span style="color: #0600FF;">foreach</span></a><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=foreach&SearchContentClassID=23"><span style="color: #0600FF;">foreach</span></a><span style="color: #66cc66;">&#125;</span> &nbsp;</pre><a name="eztoc237959_2" id="eztoc237959_2"></a><h2>References</h2> <ul> <li>Doc: N/a</li> </ul> Mon, 17 Aug 2009 06:59:35 GMT Template logic to fetch random content object https://ezpedia.org/snippet/template_logic_to_fetch_random_content_object https://ezpedia.org/snippet/template_logic_to_fetch_random_content_object <div class="object-center"> <p class="editor_motivation">This is a <a href="/es/template/stub">Stub</a> article. Help the eZ Publish community by expanding it!</p></div><a name="eztoc115740_1" id="eztoc115740_1"></a><h2>Example template</h2><p>The following example shows how to fetch a random content objeect, an image in this example.</p> <pre class="eztemplate" style="font-family:monospace;"><span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=def&SearchContentClassID=34"><span style="color: #0600FF;">def</span></a> <span style="color: #0000bb;">$nrimages</span><span style="color: #66cc66;">=</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=fetch&SearchContentClassID=31"><span style="color: #0600FF;">fetch</span></a><span style="color: #66cc66;">&#40;</span> <span style="color: #dd0000;">'content'</span>, <span style="color: #dd0000;">'tree_count'</span>, <a href="https://ez.no/doc/content/advancedsearch?SearchText=hash&SearchContentClassID=31"><span style="color: #0600FF;">hash</span></a><span style="color: #66cc66;">&#40;</span> <span style="color: #dd0000;">'parent_node_id'</span>, <span style="color: #cc66cc;">2</span>, <span style="color: #dd0000;">'class_filter_type'</span>, <span style="color: #dd0000;">'include'</span>, <span style="color: #dd0000;">'class_filter_array'</span>, <a href="https://ez.no/doc/content/advancedsearch?SearchText=array&SearchContentClassID=31"><span style="color: #0600FF;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #dd0000;">'image'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=def&SearchContentClassID=34"><span style="color: #0600FF;">def</span></a> <span style="color: #0000bb;">$randomimage</span><span style="color: #66cc66;">=</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=fetch&SearchContentClassID=31"><span style="color: #0600FF;">fetch</span></a><span style="color: #66cc66;">&#40;</span> <span style="color: #dd0000;">'content'</span>, <span style="color: #dd0000;">'tree'</span>, <a href="https://ez.no/doc/content/advancedsearch?SearchText=hash&SearchContentClassID=31"><span style="color: #0600FF;">hash</span></a><span style="color: #66cc66;">&#40;</span> <span style="color: #dd0000;">'parent_node_id'</span>, <span style="color: #cc66cc;">2</span>, <span style="color: #dd0000;">'class_filter_type'</span>, <span style="color: #dd0000;">'include'</span>, <span style="color: #dd0000;">'class_filter_array'</span>, <a href="https://ez.no/doc/content/advancedsearch?SearchText=array&SearchContentClassID=31"><span style="color: #0600FF;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #dd0000;">'image'</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #dd0000;">'offset'</span>, <a href="https://ez.no/doc/content/advancedsearch?SearchText=rand&SearchContentClassID=31"><span style="color: #0600FF;">rand</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>, <a href="https://ez.no/doc/content/advancedsearch?SearchText=dec&SearchContentClassID=31"><span style="color: #0600FF;">dec</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000bb;">$nrimages</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #dd0000;">'limit'</span>, <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=content_view_gui&SearchContentClassID=34"><span style="color: #0600FF;">content_view_gui</span></a> <span style="color: #007700;">content_object</span><span style="color: #66cc66;">=</span><span style="color: #0000bb;">$randomimage</span><span style="color: #66cc66;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#93;</span> <span style="color: #007700;">view</span><span style="color: #66cc66;">=</span>embed<span style="color: #66cc66;">&#125;</span></pre><a name="eztoc115740_2" id="eztoc115740_2"></a><h2>Reference</h2> <ul> <li>Forum: N/A</li> </ul> Mon, 17 Aug 2009 06:57:40 GMT Script to delete all nodes under a node in content structure https://ezpedia.org/snippets_for_ez_publish_3/script_to_delete_all_nodes_under_a_node_in_content_structure https://ezpedia.org/snippets_for_ez_publish_3/script_to_delete_all_nodes_under_a_node_in_content_structure <div class="object-right"><p class="version_info_ezp3">This is compatible with <a href="/es/ez/ez_publish_3" target="_self">eZ Publish 3</a>.</p></div><a name="eztoc383584_1" id="eztoc383584_1"></a><h2>About</h2><p> This is a script to delete all nodes under some tree.<br />Please note that this script may use large amounts of memory.</p><p>A better solution has been developed called, 'batchtool'. Try using <a href="https://projects.ez.no/batchtool" target="_self">batchtool</a> instead of this script snippet example. </p><a name="eztoc383584_2" id="eztoc383584_2"></a><h2>Source</h2> <pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> &nbsp; <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'lib/ezutils/classes/ezcli.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'kernel/classes/ezscript.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'kernel/classes/ezcontentobjecttreenode.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">function</span> deleteNodes<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$classID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$parentNodeID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$depth</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <a href="https://www.php.net/global"><span style="color: #990000;">global</span></a> <span style="color: #000088;">$db</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$deleteIDArray</span> <span style="color: #339933;">=</span> <a href="https://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$nodeArray</span> <span style="color: #339933;">=&amp;</span> eZContentObjectTreeNode<span style="color: #339933;">::</span><span style="color: #004000;">subTree</span><span style="color: #009900;">&#40;</span> <a href="https://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'ClassFilterType'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'include'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'ClassFilterArray'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$classID</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Depth'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$depth</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$parentNodeID</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <a href="https://www.php.net/print"><span style="color: #990000;">print</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Deleting &quot;</span> <span style="color: #339933;">.</span> <a href="https://www.php.net/count"><span style="color: #990000;">count</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$nodeArray</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; nodes. If that is not what you want it would be good to press ctrl-c now.. deleting starts in 20 seconds!!<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <a href="https://www.php.net/sleep"><span style="color: #990000;">sleep</span></a><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">20</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$deletecount</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$deleteIDArray</span> <span style="color: #339933;">=</span> <a href="https://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$nodeArray</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$node</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <a href="https://www.php.net/print"><span style="color: #990000;">print</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Deleting node &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'main_node_id'</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">' , &quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'url_alias'</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;'<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> eZContentObjectTreeNode<span style="color: #339933;">::</span><span style="color: #004000;">removeSubtrees</span><span style="color: #009900;">&#40;</span> <a href="https://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'main_node_id'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">false</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$deletecount</span><span style="color: #339933;">++;</span> <a href="https://www.php.net/print"><span style="color: #990000;">print</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$deletecount</span>, &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span> &nbsp; <span style="color: #000088;">$cli</span> <span style="color: #339933;">=&amp;</span> eZCLI<span style="color: #339933;">::</span><span style="color: #004000;">instance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #666666; font-style: italic;">// change the admin-password! see below ...</span> &nbsp; <span style="color: #000088;">$script</span> <span style="color: #339933;">=&amp;</span> eZScript<span style="color: #339933;">::</span><span style="color: #004000;">instance</span><span style="color: #009900;">&#40;</span> <a href="https://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'description'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;delete nodes ...<span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;delete main nodes ...,<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'use-session'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'use-modules'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'use-extensions'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'user'</span> <span style="color: #339933;">=&gt;</span> <a href="https://www.php.net/array"><span style="color: #990000;">array</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'login'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'admin'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'password'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'ADMINPASS'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$script</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">startup</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$options</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$script</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getOptions</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$script</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">initialize</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <a href="https://www.php.net/set_time_limit"><span style="color: #990000;">set_time_limit</span></a><span style="color: #009900;">&#40;</span> <span style="color: #cc66cc;">0</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// 'deleteNodes' function, used to remove all nodes under passed node_id</span> <span style="color: #666666; font-style: italic;">// example usage of 'deleteNodes' function: deleteNodes( $classID, $parentNodeID, $depth )</span> &nbsp; deleteNodes<span style="color: #009900;">&#40;</span> <a href="https://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'article'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">6713</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">10</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000000; font-weight: bold;">?&gt;</span></pre> Sun, 16 Aug 2009 13:06:17 GMT Copying objects https://ezpedia.org/snippets_for_ez_publish_3/copying_objects https://ezpedia.org/snippets_for_ez_publish_3/copying_objects <div class="object-right"><p class="version_info_ezp3">This is compatible with <a href="/es/ez/ez_publish_3" target="_self">eZ Publish 3</a>.</p></div><a name="eztoc383640_1" id="eztoc383640_1"></a><h2>Compatibility</h2><p>For all eZ publish versions prior to 3.8, replace</p> <pre class="" style="font-family:monospace;">$assignment-&gt;purge<span class="br0">&#40;</span><span class="br0">&#41;</span>;</pre><p>with</p> <pre class="" style="font-family:monospace;">$assignment-&gt;remove<span class="br0">&#40;</span><span class="br0">&#41;</span>;</pre><a name="eztoc383640_2" id="eztoc383640_2"></a><h2>Code sample</h2><p>The following code copies an existing object and gives it one location in the node tree. It was taken from the copy view of the content module (kernel/content/copy.php).</p><p>The used variables are:</p> <ul> <li>$object: instance of eZContentObject you want to copy</li> <li>$newParentNodeID: node id of the parent for the new object</li> <li>$allVersions: true if you want to copy all versions of the object to the new object, false if you only want to copy the currently published version</li> </ul> <pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;lib/ezdb/classes/ezdb.php&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$db</span> <span style="color: #339933;">=&amp;</span> eZDB<span style="color: #339933;">::</span><span style="color: #004000;">instance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">begin</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$newObject</span> <span style="color: #339933;">=&amp;</span> <span style="color: #000088;">$object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">copy</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$allVersions</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$curVersion</span> <span style="color: #339933;">=&amp;</span> <span style="color: #000088;">$newObject</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'current_version'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$curVersionObject</span> <span style="color: #339933;">=&amp;</span> <span style="color: #000088;">$newObject</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'current'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$newObjAssignments</span> <span style="color: #339933;">=&amp;</span> <span style="color: #000088;">$curVersionObject</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'node_assignments'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <a href="https://www.php.net/unset"><span style="color: #990000;">unset</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$curVersionObject</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #666666; font-style: italic;">// remove old node assignments</span> <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$newObjAssignments</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$assignment</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$assignment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">purge</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> &nbsp; <span style="color: #666666; font-style: italic;">// and create a new one</span> <span style="color: #000088;">$nodeAssignment</span> <span style="color: #339933;">=</span> eZNodeAssignment<span style="color: #339933;">::</span><span style="color: #004000;">create</span><span style="color: #009900;">&#40;</span> <a href="https://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'contentobject_id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$newObject</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'id'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'contentobject_version'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$curVersion</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'parent_node'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$newParentNodeID</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'is_main'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$nodeAssignment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">store</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #666666; font-style: italic;">// publish the newly created object</span> <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'lib/ezutils/classes/ezoperationhandler.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> eZOperationHandler<span style="color: #339933;">::</span><span style="color: #004000;">execute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'content'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'publish'</span><span style="color: #339933;">,</span> <a href="https://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'object_id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$newObject</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'id'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'version'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$curVersion</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Update &quot;is_invisible&quot; attribute for the newly created node.</span> <span style="color: #000088;">$newNode</span> <span style="color: #339933;">=&amp;</span> <span style="color: #000088;">$newObject</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'main_node'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> eZContentObjectTreeNode<span style="color: #339933;">::</span><span style="color: #004000;">updateNodeVisibility</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$newNode</span><span style="color: #339933;">,</span> <span style="color: #000088;">$newParentNode</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">commit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre> Sun, 16 Aug 2009 12:35:27 GMT Assigning sections https://ezpedia.org/snippets_for_ez_publish_3/assigning_sections https://ezpedia.org/snippets_for_ez_publish_3/assigning_sections <div class="object-right"><p class="version_info_ezp3">This is compatible with <a href="/es/ez/ez_publish_3" target="_self">eZ Publish 3</a>.</p></div> <div class="object-center"> <p class="editor_motivation">This is a <a href="/es/template/stub">Stub</a> article. Help the eZ Publish community by expanding it!</p></div><a name="eztoc383624_1" id="eztoc383624_1"></a><h2>To a subtree</h2> <pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'kernel/classes/ezcontentobjecttreenode.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; eZContentObjectTreeNode<span style="color: #339933;">::</span><span style="color: #004000;">assignSectionToSubTree</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$nodeID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$sectionID</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>include_once<span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'kernel/classes/ezcontentcachemanager.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> eZContentCacheManager<span style="color: #339933;">::</span><span style="color: #004000;">clearAllContentCache</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp;</pre><a name="eztoc383624_2" id="eztoc383624_2"></a><h2>To a single node</h2> <pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Missing example</span></pre> Sun, 16 Aug 2009 12:35:26 GMT Assigning roles https://ezpedia.org/snippets_for_ez_publish_3/assigning_roles https://ezpedia.org/snippets_for_ez_publish_3/assigning_roles <div class="object-right"><p class="version_info_ezp3">This is compatible with <a href="/es/ez/ez_publish_3" target="_self">eZ Publish 3</a>.</p></div> <div class="object-center"> <p class="editor_motivation">This is a <a href="/es/template/stub">Stub</a> article. Help the eZ Publish community by expanding it!</p></div><a name="eztoc383632_1" id="eztoc383632_1"></a><h2>Predefined variables</h2> <ul> <li>$roleID: ID of the role</li> <li>$objectID: id of a user or user group content object you want to assign the role to</li> <li>$limitIdent: either null, Subtree or Section</li> <li>$limitValue: either null, a node path string (in case $limitIdent is 'Subtree') or a section id (in case $limitIdent is 'Section')</li> </ul> <pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'kernel/classes/ezrole.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$role</span> <span style="color: #339933;">=</span> eZRole<span style="color: #339933;">::</span><span style="color: #004000;">fetch</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$roleID</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$role</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">assignToUser</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$objectID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$limitIdent</span><span style="color: #339933;">,</span> <span style="color: #000088;">$limitValue</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; eZRole<span style="color: #339933;">::</span><span style="color: #004000;">expireCache</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'kernel/classes/ezcontentcachemanager.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> eZContentCacheManager<span style="color: #339933;">::</span><span style="color: #004000;">clearAllContentCache</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'kernel/classes/datatypes/ezuser/ezuser.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> eZUser<span style="color: #339933;">::</span><span style="color: #004000;">cleanupCache</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre> Sun, 16 Aug 2009 12:35:26 GMT Moving a node https://ezpedia.org/snippets_for_ez_publish_3/moving_a_node https://ezpedia.org/snippets_for_ez_publish_3/moving_a_node <div class="object-right"><p class="version_info_ezp3">This is compatible with <a href="/es/ez/ez_publish_3" target="_self">eZ Publish 3</a>.</p></div><a name="eztoc383608_1" id="eztoc383608_1"></a><h2>Policy checking</h2><p>You can remove policy checking by removing the condition with <i>$node-&gt;canMoveFrom() &amp;&amp; $newParentNode-&gt;canMoveTo( $classID )</i>.</p><a name="eztoc383608_2" id="eztoc383608_2"></a><h2>Code sample</h2><p>The following code is based on a part of the action view of the content module (kernel/content/action.php). The known variables are:</p> <ul> <li>$node: the node we're trying to move</li> <li>$newParentNode: the destination node we want to place our node under</li> </ul> <pre class="php" style="font-family:monospace;"><span style="color: #000088;">$object</span> <span style="color: #339933;">=&amp;</span> <span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">object</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$class</span> <span style="color: #339933;">=&amp;</span> <span style="color: #000088;">$object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">contentClass</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$classID</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$class</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'id'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><a href="https://www.php.net/in_array"><span style="color: #990000;">in_array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'node_id'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$newParentNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">pathArray</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">canMoveFrom</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$newParentNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">canMoveTo</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$classID</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'kernel/classes/ezcontentobjecttreenodeoperations.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> eZContentObjectTreeNodeOperations<span style="color: #339933;">::</span><span style="color: #004000;">move</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'node_id'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$newParentNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'node_id'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span></pre> Sun, 16 Aug 2009 12:35:25 GMT Adding collaboration notification rules https://ezpedia.org/snippets_for_ez_publish_3/adding_collaboration_notification_rules https://ezpedia.org/snippets_for_ez_publish_3/adding_collaboration_notification_rules <div class="object-right"><p class="version_info_ezp3">This is compatible with <a href="/es/ez/ez_publish_3" target="_self">eZ Publish 3</a>.</p></div> <div class="object-center"> <p class="editor_motivation">This is a <a href="/es/template/stub">Stub</a> article. Help the eZ Publish community by expanding it!</p></div><p>The following <a href="/es/snippet/php_ez_publish_api_source_code_examples" target="_self">code sample</a> shows you how to create a new collaboration notification rule for a specific user. The known variables are:</p> <ul> <li>$collaborationIdentifier: identifier of the collaboration type, for example <i>ezapprove</i></li> <li>$userID: the content object id of the user we want to create the rule for</li> </ul> <pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'kernel/classes/notification/handler/ezcollaborationnotification/ezcollaborationnotificationrule.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$existing</span> <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>eZCollaborationNotificationRule<span style="color: #339933;">::</span><span style="color: #004000;">fetchItemTypeList</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$collaborationIdentifier</span><span style="color: #339933;">,</span> <a href="https://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$userID</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <a href="https://www.php.net/count"><span style="color: #990000;">count</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$existing</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$rule</span> <span style="color: #339933;">=</span> <span style="color: #339933;">&amp;</span>eZCollaborationNotificationRule<span style="color: #339933;">::</span><span style="color: #004000;">create</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$collaborationIdentifier</span><span style="color: #339933;">,</span> <span style="color: #000088;">$userID</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$rule</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">store</span><span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span></pre> Sun, 16 Aug 2009 12:35:25 GMT RSS Delete Script - Allows you to limit the amount of RSS data in the system https://ezpedia.org/snippets_for_ez_publish_3/rss_delete_script_allows_you_to_limit_the_amount_of_rss_data_in_the_system https://ezpedia.org/snippets_for_ez_publish_3/rss_delete_script_allows_you_to_limit_the_amount_of_rss_data_in_the_system <div class="object-right"><p class="version_info_ezp3">This is compatible with <a href="/es/ez/ez_publish_3" target="_self">eZ Publish 3</a>.</p></div><a name="eztoc383592_1" id="eztoc383592_1"></a><h2>Warning</h2><p>This script was created for older versions of eZ Publish.</p><p>Users of eZ Publish 4.0+ should use <a href="https://projects.ez.no/bccleanuprss" target="_self">BC Cleanup RSS</a> instead.</p><a name="eztoc383592_2" id="eztoc383592_2"></a><h2>About</h2><p>The script <b>runcronjobs.php</b> goes out to all the active incoming <a href="/es/ez/rss" target="_self">RSS</a> feeds in the system to collect content.</p><p>The following script ( <i>rssdelete.php</i>) can be added to the <b>runcronjobs</b> list by updating <b>cronjob.ini</b>, and placing the script in <b>cronjobs</b>, set to run immediately after <b>rssimport.php</b>.</p><p>It can be controlled through <b>site.ini</b> by setting <i>[RSSSettings] MaxRSSObjects</i> to the maximum number of RSS Objects you want in the system. If you forget to set the value, it will delete all RSS content immediately after import.</p><a name="eztoc383592_2_1" id="eztoc383592_2_1"></a><h3><b>Notes:</b></h3><p>This retrieves all the <b>RSS</b> nodes sorted in descending order of publication. Thus, the most recent nodes will be returned first. An offset is used to skip the ini setting - so if there are less than that number of elements, no deletion will occur. You can add other filtering. This also disregards the location of the content, so as feeds are created and removed, the code will still run fine.</p><a name="eztoc383592_3" id="eztoc383592_3"></a><h2>Script</h2><p>You can run it on the command line for testing, because runcronjobs can take a while to run.</p><p><b>Thanks to those who posted the code this is based on</b></p> <pre class="php" style="font-family:monospace;">&nbsp; <span style="color: #666666; font-style: italic;">//init shell script</span> <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'kernel/classes/ezcontentobject.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'kernel/classes/ezcontentobjecttreenode.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'kernel/classes/ezcontentobjecttreenodeoperations.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;lib/ezutils/classes/ezextension.php&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;lib/ezutils/classes/ezmodule.php&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'lib/ezutils/classes/ezcli.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <a href="https://www.php.net/define"><span style="color: #990000;">define</span></a> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'SUBTREE_LIMIT'</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">50</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="https://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$script</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'kernel/classes/ezscript.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$script</span> <span style="color: #339933;">=&amp;</span> eZScript<span style="color: #339933;">::</span><span style="color: #004000;">instance</span><span style="color: #009900;">&#40;</span> <a href="https://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'debug-message'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'use-session'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'use-modules'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'use-extensions'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000000; font-weight: bold;">true</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$script</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">startup</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$script</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">initialize</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$standalone</span><span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">true</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #000088;">$standalone</span><span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">false</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="https://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cli</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$cli</span> <span style="color: #339933;">=&amp;</span> eZCLI<span style="color: #339933;">::</span><span style="color: #004000;">instance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$cli</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setUseStyles</span><span style="color: #009900;">&#40;</span> <span style="color: #000000; font-weight: bold;">true</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// enable colors</span> <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;kernel/classes/ezdatatype.php&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;kernel/classes/datatypes/ezuser/ezusersetting.php&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;lib/ezutils/classes/ezmail.php&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">include_once</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'kernel/classes/datatypes/ezuser/ezuser.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$user</span> <span style="color: #339933;">=</span> eZUser<span style="color: #339933;">::</span><span style="color: #004000;">fetchByName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'admin'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//*** ez administror</span> <span style="color: #000088;">$userID</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'contentobject_id'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> eZUser<span style="color: #339933;">::</span><span style="color: #004000;">setCurrentlyLoggedInUser</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$user</span><span style="color: #339933;">,</span> <span style="color: #000088;">$userID</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$today</span><span style="color: #339933;">=</span><a href="https://www.php.net/getdate"><span style="color: #990000;">getdate</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$time</span><span style="color: #339933;">=</span><a href="https://www.php.net/mktime"><span style="color: #990000;">mktime</span></a><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #000088;">$today</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'mon'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #000088;">$today</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'mday'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #000088;">$today</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'year'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$cli</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">output</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Checking for RSS objects'</span><span style="color: #339933;">,</span><span style="color: #000000; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'lib/ezutils/classes/ezini.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$ini</span> <span style="color: #339933;">=&amp;</span> eZINI<span style="color: #339933;">::</span><span style="color: #004000;">instance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$max_RSS_objects</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>int<span style="color: #009900;">&#41;</span><span style="color: #000088;">$ini</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">variable</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;RSSSettings&quot;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">&quot;MaxRSSObjects&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$cli</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">output</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Current limit is '</span><span style="color: #339933;">.</span><span style="color: #000088;">$max_RSS_objects</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' RSS objects per feed'</span><span style="color: #339933;">,</span><span style="color: #000000; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #666666; font-style: italic;">//fetch this class</span> <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'kernel/classes/ezrssimport.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$rssImportArray</span> <span style="color: #339933;">=</span> eZRSSImport<span style="color: #339933;">::</span><span style="color: #004000;">fetchActiveList</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span> <a href="https://www.php.net/array_keys"><span style="color: #990000;">array_keys</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$rssImportArray</span> <span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$rssImportKey</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">// Get RSSImport object</span> <span style="color: #000088;">$rssImport</span> <span style="color: #339933;">=&amp;</span> <span style="color: #000088;">$rssImportArray</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$rssImportKey</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$parentNodeID</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$rssImport</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'destination_node_id'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Get parent treenode object</span> <span style="color: #000088;">$cli</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">output</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$rssImport</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #000000; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> get_RSS_nodes<span style="color: #009900;">&#40;</span><span style="color: #000088;">$time</span><span style="color: #339933;">,</span><span style="color: #000088;">$max_RSS_objects</span><span style="color: #339933;">,</span><span style="color: #000088;">$parentNodeID</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> &nbsp; <span style="color: #000088;">$cli</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">output</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Done'</span><span style="color: #339933;">,</span><span style="color: #000000; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$standalone</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$script</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">shutdown</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000000; font-weight: bold;">function</span> get_RSS_nodes <span style="color: #009900;">&#40;</span><span style="color: #000088;">$today</span><span style="color: #339933;">,</span><span style="color: #000088;">$max_RSS_objects</span><span style="color: #339933;">,</span><span style="color: #000088;">$parentNodeID</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <a href="https://www.php.net/global"><span style="color: #990000;">global</span></a> <span style="color: #000088;">$cli</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$max_RSS_objects</span> <span style="color: #339933;">===</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$offset</span><span style="color: #339933;">=</span><span style="color: #000088;">$max_RSS_objects</span><span style="color: #339933;">;</span> <span style="color: #000088;">$done</span><span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">FALSE</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">do</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$params</span><span style="color: #339933;">=</span><a href="https://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'ClassFilterType'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'include'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'ClassFilterArray'</span> <span style="color: #339933;">=&gt;</span> <a href="https://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">33</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Limit'</span> <span style="color: #339933;">=&gt;</span> SUBTREE_LIMIT<span style="color: #339933;">,</span> <span style="color: #0000ff;">'Depth'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Offset'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$offset</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'SortBy'</span> <span style="color: #339933;">=&gt;</span> <a href="https://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'published'</span><span style="color: #339933;">,</span><span style="color: #000000; font-weight: bold;">false</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">// 'AttributeFilter' =&gt; array('and',array('published','&lt;=',$today)),</span> <span style="color: #0000ff;">'status'</span> <span style="color: #339933;">=&gt;</span> EZ_CONTENT_OBJECT_STATUS_PUBLISHED<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$childNodes</span> <span style="color: #339933;">=&amp;</span> eZContentObjectTreeNode<span style="color: #339933;">::</span><span style="color: #004000;">subTree</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$params</span><span style="color: #339933;">,</span><span style="color: #000088;">$parentNodeID</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="https://www.php.net/count"><span style="color: #990000;">count</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$childNodes</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">===</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$done</span><span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">TRUE</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$childNodes</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$child</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$deleteIDArray</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$id</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$child</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'main_node_id'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$cli</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">output</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Deleting: '</span><span style="color: #339933;">.</span><span style="color: #000088;">$child</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' ['</span><span style="color: #339933;">.</span><span style="color: #000088;">$id</span><span style="color: #339933;">.</span><span style="color: #0000ff;">']'</span><span style="color: #339933;">,</span><span style="color: #000000; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> eZContentObjectTreeNode<span style="color: #339933;">::</span><span style="color: #004000;">removeSubtrees</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$deleteIDArray</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">false</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <a href="https://www.php.net/unset"><span style="color: #990000;">unset</span></a> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$childNodes</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$done</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> &nbsp; &nbsp; &nbsp;</pre><a name="eztoc383592_4" id="eztoc383592_4"></a><h2>External referencce</h2> <ul> <li>Forum: <a href="https://ez.no/community/forum/setup_design/rss_import_and_multiple_feeds" target="_self">RSS import and multiple feeds</a> </li> <li>Forum: <a href="https://ez.no/community/forum/general/best_way_to_removing_old_rss_files" target="_self">Best way to removing old rss files</a> </li> </ul> Sun, 16 Aug 2009 12:35:24 GMT Adding subtree notification rules https://ezpedia.org/snippets_for_ez_publish_3/adding_subtree_notification_rules https://ezpedia.org/snippets_for_ez_publish_3/adding_subtree_notification_rules <div class="object-right"><p class="version_info_ezp3">This is compatible with <a href="/es/ez/ez_publish_3" target="_self">eZ Publish 3</a>.</p></div> <div class="object-center"> <p class="editor_motivation">This is a <a href="/es/template/stub">Stub</a> article. Help the eZ Publish community by expanding it!</p></div><a name="eztoc383600_1" id="eztoc383600_1"></a><h2>Code sample</h2><p>The defined variables are:</p> <ul> <li>$nodeID: id of the node for which we want to add a subtree notification rule</li> <li>$userID: id of the user for which we want to add the notification rule</li> </ul> <pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'kernel/classes/notification/handler/ezsubtree/ezsubtreenotificationrule.php'</span> <span style="color: #009900;">&#41;</span> &nbsp; <span style="color: #000088;">$nodeIDList</span> <span style="color: #339933;">=&amp;</span> eZSubtreeNotificationRule<span style="color: #339933;">::</span><span style="color: #004000;">fetchNodesForUserID</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$userID</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">false</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><a href="https://www.php.net/in_array"><span style="color: #990000;">in_array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$nodeID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$nodeIDList</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$rule</span> <span style="color: #339933;">=&amp;</span> eZSubtreeNotificationRule<span style="color: #339933;">::</span><span style="color: #004000;">create</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$nodeID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$userID</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$rule</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">store</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span></pre> Sun, 16 Aug 2009 12:35:24 GMT Creating new content object language translations with PHP https://ezpedia.org/snippets_for_ez_publish_3/creating_new_content_object_language_translations_with_php https://ezpedia.org/snippets_for_ez_publish_3/creating_new_content_object_language_translations_with_php <div class="object-center"> <p class="editor_motivation">This is a <a href="/es/template/stub">Stub</a> article. Help the eZ Publish community by expanding it!</p></div> Sun, 16 Aug 2009 12:35:23 GMT eZ cli data creation script (unstable) https://ezpedia.org/snippets_for_ez_publish_3/ez_cli_data_creation_script_unstable https://ezpedia.org/snippets_for_ez_publish_3/ez_cli_data_creation_script_unstable <div class="object-right"><p class="version_info_ezp3">This is compatible with <a href="/es/ez/ez_publish_3" target="_self">eZ Publish 3</a>.</p></div> <pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> &nbsp; <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'lib/ezutils/classes/ezcli.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'kernel/classes/ezscript.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'kernel/classes/ezcontentclassattribute.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'kernel/classes/ezcontentclass.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'kernel/classes/ezcontentobject.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'kernel/classes/ezcontentobjectversion.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'lib/ezutils/classes/ezoperationhandler.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//PEAR Console Bar</span> <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Console/ProgressBar.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #666666; font-style: italic;">//CLI stuff</span> <span style="color: #000088;">$cli</span> <span style="color: #339933;">=&amp;</span> eZCLI<span style="color: #339933;">::</span><span style="color: #004000;">instance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$script</span> <span style="color: #339933;">=&amp;</span> eZScript<span style="color: #339933;">::</span><span style="color: #004000;">instance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$script</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">startup</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$options</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$script</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getOptions</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$script</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">initialize</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; &nbsp; <span style="color: #000088;">$classID</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">16</span><span style="color: #339933;">;</span> <span style="color: #000088;">$nodeID</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">59</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #000088;">$class</span> <span style="color: #339933;">=</span> eZContentClass<span style="color: #339933;">::</span><span style="color: #004000;">fetch</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$classID</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$cli</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">output</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Error: Could not fetch class'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> &nbsp; <span style="color: #000088;">$node</span> <span style="color: #339933;">=</span> eZContentObjectTreeNode<span style="color: #339933;">::</span><span style="color: #004000;">fetch</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$nodeID</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$node</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$cli</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">output</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Error: no mapped parent node'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> &nbsp; <span style="color: #000088;">$object</span> <span style="color: #339933;">=&amp;</span> <span style="color: #000088;">$class</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">instantiate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$object</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$cli</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">output</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Error: could not create object'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> &nbsp; <span style="color: #000088;">$objectID</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'id'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$cli</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">output</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Object ID: '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$objectID</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$cli</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">output</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Node ID: '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$nodeID</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$cli</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">output</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$nodeAssignment</span> <span style="color: #339933;">=</span> eZNodeAssignment<span style="color: #339933;">::</span><span style="color: #004000;">create</span><span style="color: #009900;">&#40;</span> <a href="https://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'contentobject_id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$objectID</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'contentobject_version'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'parent_node'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$nodeID</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'is_main'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$nodeAssignment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">store</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$dataMap</span> <span style="color: #339933;">=&amp;</span> <span style="color: #000088;">$object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dataMap</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span> <a href="https://www.php.net/array_keys"><span style="color: #990000;">array_keys</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$dataMap</span> <span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">//$cli-&gt;output($key);</span> &nbsp; <span style="color: #000088;">$attribute</span> <span style="color: #339933;">=&amp;</span> <span style="color: #000088;">$dataMap</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$classAttributeID</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$attribute</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'contentclassattribute_id'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$attribute</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAttribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'data_text'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'I have a dream!'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span>eZOperationHandler<span style="color: #339933;">::</span><span style="color: #004000;">execute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'content'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'publish'</span><span style="color: #339933;">,</span> <a href="https://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'object_id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$objectID</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'version'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">// TODO:</span> <span style="color: #666666; font-style: italic;">// add to the list of errors</span> <span style="color: #000088;">$cli</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">output</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Error: Could not execute'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> &nbsp; <span style="color: #000000; font-weight: bold;">function</span> cliGetLine<span style="color: #009900;">&#40;</span><span style="color: #000088;">$default</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #000088;">$input</span> <span style="color: #339933;">=</span> <a href="https://www.php.net/strtolower"><span style="color: #990000;">strtolower</span></a><span style="color: #009900;">&#40;</span><a href="https://www.php.net/trim"><span style="color: #990000;">trim</span></a><span style="color: #009900;">&#40;</span><a href="https://www.php.net/fgets"><span style="color: #990000;">fgets</span></a><span style="color: #009900;">&#40;</span>STDIN<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">return</span> <span style="color: #009900;">&#40;</span><a href="https://www.php.net/strlen"><span style="color: #990000;">strlen</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$input</span><span style="color: #009900;">&#41;</span> ? <span style="color: #000088;">$input</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$default</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> &nbsp; <span style="color: #666666; font-style: italic;">////////////////////////// </span> <span style="color: #000088;">$script</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">shutdown</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000000; font-weight: bold;">?&gt;</span></pre> Sun, 16 Aug 2009 12:35:22 GMT eZ cli lorem ipsum data creation script (unstable) https://ezpedia.org/snippets_for_ez_publish_3/ez_cli_lorem_ipsum_data_creation_script_unstable https://ezpedia.org/snippets_for_ez_publish_3/ez_cli_lorem_ipsum_data_creation_script_unstable <div class="object-right"><p class="version_info_ezp3">This is compatible with <a href="/es/ez/ez_publish_3" target="_self">eZ Publish 3</a>.</p></div> <pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #009933; font-style: italic;">/** * Lorem Ipsum CLI * * * @author Ammar Ibrahim */</span> &nbsp; <span style="color: #666666; font-style: italic;">// ------------------------------------------------------------------------ </span> &nbsp; &nbsp; <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'lib/ezutils/classes/ezcli.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'kernel/classes/ezscript.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'kernel/classes/ezcontentclassattribute.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'kernel/classes/ezcontentclass.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'kernel/classes/ezcontentobject.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'kernel/classes/ezcontentobjectversion.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'lib/ezutils/classes/ezoperationhandler.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'extension/loremipsum/classes/ezloremipsum.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; &nbsp; <a href="https://www.php.net/set_include_path"><span style="color: #990000;">set_include_path</span></a><span style="color: #009900;">&#40;</span> <a href="https://www.php.net/ini_get"><span style="color: #990000;">ini_get</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'include_path'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> PATH_SEPARATOR <span style="color: #339933;">.</span> <span style="color: #0000ff;">'PEAR/'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Console/ProgressBar.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$cli</span> <span style="color: #339933;">=&amp;</span> eZCLI<span style="color: #339933;">::</span><span style="color: #004000;">instance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$script</span> <span style="color: #339933;">=&amp;</span> eZScript<span style="color: #339933;">::</span><span style="color: #004000;">instance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$script</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">startup</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$options</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$script</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getOptions</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$script</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">initialize</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$cli</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">output</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Enter parent node ID (69):'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$parameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'nodes'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> cliGetLine<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'69'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$cli</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">output</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Enter number of items to create (1000):'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$parameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'count'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> cliGetLine<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'1000'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$cli</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">output</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Enter sleep in seconds after every node creation, &quot;0&quot; no sleep(0):'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$parameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'sleep'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> cliGetLine<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'0'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #666666; font-style: italic;">//get all content classes </span> <span style="color: #000088;">$classes</span> <span style="color: #339933;">=</span> eZContentClass<span style="color: #339933;">::</span><span style="color: #004000;">fetchList</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$classes</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$class</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #000088;">$cli</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">output</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$class</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'. '</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$class</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Name</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #000088;">$cli</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">output</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Enter type of nodes to create(16):'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$parameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'class'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> cliGetLine<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'16'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #666666; font-style: italic;">//get all attributes of the selected class </span> <span style="color: #000088;">$attributes</span> <span style="color: #339933;">=</span> eZContentClassAttribute<span style="color: #339933;">::</span><span style="color: #004000;">fetchListByClassID</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$parameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'class'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$attributes</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$attribute</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #000088;">$attribHint</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$attribute</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">Name</span><span style="color: #339933;">;</span> <span style="color: #000088;">$attribHint</span> <span style="color: #339933;">.=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$attribute</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">IsRequired</span> ? <span style="color: #0000ff;">' (Required)'</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">', '</span><span style="color: #339933;">;</span> <span style="color: #000088;">$attribHint</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$attribute</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">DataTypeString</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$cli</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">output</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$attribHint</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">switch</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$attribute</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">DataTypeString</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'ezstring'</span><span style="color: #339933;">;</span> <span style="color: #000088;">$cli</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">output</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Generate min,max words (4,6)'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <a href="https://www.php.net/list"><span style="color: #990000;">list</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$parameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'attributes'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$attribute</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'min_words'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$parameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'attributes'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$attribute</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'max_words'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <a href="https://www.php.net/explode"><span style="color: #990000;">explode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">','</span><span style="color: #339933;">,</span>cliGetLine<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'4,6'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'ezxmltext'</span><span style="color: #339933;">;</span> <span style="color: #000088;">$cli</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">output</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Generate min,max paragraphs (4,6)'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <a href="https://www.php.net/list"><span style="color: #990000;">list</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$parameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'attributes'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$attribute</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'min_pars'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$parameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'attributes'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$attribute</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'max_pars'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <a href="https://www.php.net/explode"><span style="color: #990000;">explode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">','</span><span style="color: #339933;">,</span>cliGetLine<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'4,6'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$cli</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">output</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Each paragraph min,max sentences (4,6)'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <a href="https://www.php.net/list"><span style="color: #990000;">list</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$parameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'attributes'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$attribute</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'min_sentences'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$parameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'attributes'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$attribute</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'max_sentences'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <a href="https://www.php.net/explode"><span style="color: #990000;">explode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">','</span><span style="color: #339933;">,</span>cliGetLine<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'4,6'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'eztext'</span><span style="color: #339933;">:</span> <span style="color: #000088;">$cli</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">output</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Generate min,max paragraphs (4,6)'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <a href="https://www.php.net/list"><span style="color: #990000;">list</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$parameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'attributes'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$attribute</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'min_pars'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$parameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'attributes'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$attribute</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'max_pars'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <a href="https://www.php.net/explode"><span style="color: #990000;">explode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">','</span><span style="color: #339933;">,</span>cliGetLine<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'4,6'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$cli</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">output</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Each paragraph min,max sentences (4,6)'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <a href="https://www.php.net/list"><span style="color: #990000;">list</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$parameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'attributes'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$attribute</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'min_sentences'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$parameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'attributes'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$attribute</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'max_sentences'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <a href="https://www.php.net/explode"><span style="color: #990000;">explode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">','</span><span style="color: #339933;">,</span>cliGetLine<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'4,6'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'ezboolean'</span><span style="color: #339933;">:</span> <span style="color: #000088;">$cli</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">output</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Generate &quot;true&quot; with probability of %(50):'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$parameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'attributes'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$attribute</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'prob'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> cliGetLine<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'50'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'ezinteger'</span><span style="color: #339933;">:</span> <span style="color: #000088;">$cli</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">output</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Generate integer min,max (0,999)'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <a href="https://www.php.net/list"><span style="color: #990000;">list</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$parameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'attributes'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$attribute</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'min'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$parameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'attributes'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$attribute</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'max'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <a href="https://www.php.net/explode"><span style="color: #990000;">explode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">','</span><span style="color: #339933;">,</span>cliGetLine<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'0,999'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'ezfloat'</span><span style="color: #339933;">:</span> <span style="color: #000088;">$cli</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">output</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Generate float min,max (0,999)'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <a href="https://www.php.net/list"><span style="color: #990000;">list</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$parameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'attributes'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$attribute</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'min'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$parameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'attributes'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$attribute</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'max'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <a href="https://www.php.net/explode"><span style="color: #990000;">explode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">','</span><span style="color: #339933;">,</span>cliGetLine<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'0,999'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'ezprice'</span><span style="color: #339933;">:</span> <span style="color: #000088;">$cli</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">output</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Generate price min,max (0,999)'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <a href="https://www.php.net/list"><span style="color: #990000;">list</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$parameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'attributes'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$attribute</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'min'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$parameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'attributes'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$attribute</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'max'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <a href="https://www.php.net/explode"><span style="color: #990000;">explode</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">','</span><span style="color: #339933;">,</span>cliGetLine<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'0,999'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000000; font-weight: bold;">default</span><span style="color: #339933;">:</span> <span style="color: #000088;">$cli</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">output</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'Not supported, skipping.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; &nbsp; <span style="color: #009900;">&#125;</span> &nbsp; <span style="color: #666666; font-style: italic;">//blank line </span> <span style="color: #000088;">$cli</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">output</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #009900;">&#125;</span> &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$cli</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">output</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Quick mode(Y,N):'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$parameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'quick'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span> <a href="https://www.php.net/strtolower"><span style="color: #990000;">strtolower</span></a><span style="color: #009900;">&#40;</span><a href="https://www.php.net/substr"><span style="color: #990000;">substr</span></a><span style="color: #009900;">&#40;</span>cliGetLine<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'n'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'y'</span> ? <span style="color: #0000ff;">'On'</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">''</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><a href="https://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$parameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'structure'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$parameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'structure'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <a href="https://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$totalCount</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$count</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$parameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'count'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$parameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'nodes'</span><span style="color: #009900;">&#93;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$nodeID</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$nodeID</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span> int <span style="color: #009900;">&#41;</span> <span style="color: #000088;">$nodeID</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$nodeID</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$parameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'structure'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$nodeID</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$count</span><span style="color: #339933;">;</span> <span style="color: #000088;">$totalCount</span> <span style="color: #339933;">+=</span> <span style="color: #000088;">$count</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span> &nbsp; <span style="color: #000088;">$parameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'total_count'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$totalCount</span><span style="color: #339933;">;</span> <span style="color: #000088;">$parameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'created_count'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$parameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'start_time'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <a href="https://www.php.net/time"><span style="color: #990000;">time</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> &nbsp; <span style="color: #000088;">$classID</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$parameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'class'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #000088;">$class</span> <span style="color: #339933;">=</span> eZContentClass<span style="color: #339933;">::</span><span style="color: #004000;">fetch</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$classID</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">// TODO </span> <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #000088;">$attributes</span> <span style="color: #339933;">=&amp;</span> eZContentClassAttribute<span style="color: #339933;">::</span><span style="color: #004000;">fetchListByClassID</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$classID</span><span style="color: #339933;">,</span> EZ_CLASS_VERSION_STATUS_DEFINED<span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">false</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">// TODO </span> <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> &nbsp; <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$attributes</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$attribute</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$attribute</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'is_required'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span><a href="https://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$parameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'attributes'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$attribute</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'id'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">// TODO </span> <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span> &nbsp; <span style="color: #000088;">$db</span> <span style="color: #339933;">=&amp;</span> eZDB<span style="color: #339933;">::</span><span style="color: #004000;">instance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setIsSQLOutputEnabled</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; &nbsp; <span style="color: #000088;">$cli</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">output</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Generating content:'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$cli</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">output</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #666666; font-style: italic;">//progress bar stuff </span> <span style="color: #000088;">$bar</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Console_ProgressBar<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'- %fraction% [%bar%] %percent% ETA: %estimate%'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'=&gt;'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'-'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">78</span><span style="color: #339933;">,</span> <span style="color: #000088;">$parameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'count'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$bar</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">update</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span> <a href="https://www.php.net/array_keys"><span style="color: #990000;">array_keys</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$parameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'structure'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$nodeID</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> &nbsp; &nbsp; <span style="color: #000088;">$node</span> <span style="color: #339933;">=</span> eZContentObjectTreeNode<span style="color: #339933;">::</span><span style="color: #004000;">fetch</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$nodeID</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #000088;">$node</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">// TODO </span> <span style="color: #b1b100;">continue</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <a href="https://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$parameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'quick'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$parameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'quick'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$parentObject</span> <span style="color: #339933;">=&amp;</span> <span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'object'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$sectionID</span> <span style="color: #339933;">=&amp;</span> <span style="color: #000088;">$parentObject</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'section_id'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> &nbsp; <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$parameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'structure'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$nodeID</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">//check if we need to sleep this round </span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <a href="https://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$parameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'sleep'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$parameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'sleep'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <a href="https://www.php.net/sleep"><span style="color: #990000;">sleep</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$parameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'sleep'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// create object </span> <span style="color: #000088;">$object</span> <span style="color: #339933;">=&amp;</span> <span style="color: #000088;">$class</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">instantiate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$object</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">begin</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$objectID</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'id'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$nodeAssignment</span> <span style="color: #339933;">=</span> eZNodeAssignment<span style="color: #339933;">::</span><span style="color: #004000;">create</span><span style="color: #009900;">&#40;</span> <a href="https://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'contentobject_id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$objectID</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'contentobject_version'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'parent_node'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$nodeID</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'is_main'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$nodeAssignment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">store</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$dataMap</span> <span style="color: #339933;">=&amp;</span> <span style="color: #000088;">$object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dataMap</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span> <a href="https://www.php.net/array_keys"><span style="color: #990000;">array_keys</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$dataMap</span> <span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$attribute</span> <span style="color: #339933;">=&amp;</span> <span style="color: #000088;">$dataMap</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$classAttributeID</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$attribute</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'contentclassattribute_id'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <a href="https://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$parameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'attributes'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$classAttributeID</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$attributeparameters</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$parameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'attributes'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$classAttributeID</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$dataType</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$attribute</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'data_type_string'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">switch</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$dataType</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'ezstring'</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$attribute</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAttribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'data_text'</span><span style="color: #339933;">,</span> eZLoremIpsum<span style="color: #339933;">::</span><span style="color: #004000;">generateString</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$attributeparameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'min_words'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$attributeparameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'max_words'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'ezxmltext'</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$xml</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;'</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;section xmlns:image=&quot;https://ez.no/namespaces/ezpublish3/image/&quot;'</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">.</span> <span style="color: #0000ff;">' xmlns:xhtml=&quot;https://ez.no/namespaces/ezpublish3/xhtml/&quot;'</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">.</span> <span style="color: #0000ff;">' xmlns:custom=&quot;https://ez.no/namespaces/ezpublish3/custom/&quot;&gt;'</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">.</span> <span style="color: #0000ff;">' &lt;section&gt;'</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$numPars</span> <span style="color: #339933;">=</span> <a href="https://www.php.net/mt_rand"><span style="color: #990000;">mt_rand</span></a><span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span> int <span style="color: #009900;">&#41;</span> <span style="color: #000088;">$attributeparameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'min_pars'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span> int <span style="color: #009900;">&#41;</span> <span style="color: #000088;">$attributeparameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'max_pars'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$par</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$par</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$numPars</span><span style="color: #339933;">;</span> <span style="color: #000088;">$par</span><span style="color: #339933;">++</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$xml</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">' &lt;paragraph&gt;'</span><span style="color: #339933;">;</span> <span style="color: #000088;">$numSentences</span> <span style="color: #339933;">=</span> <a href="https://www.php.net/mt_rand"><span style="color: #990000;">mt_rand</span></a><span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span> int <span style="color: #009900;">&#41;</span> <span style="color: #000088;">$attributeparameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'min_sentences'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span> int <span style="color: #009900;">&#41;</span> <span style="color: #000088;">$attributeparameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'max_sentences'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$sentence</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$sentence</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$numSentences</span><span style="color: #339933;">;</span> <span style="color: #000088;">$sentence</span><span style="color: #339933;">++</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$sentence</span> <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">0</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$xml</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">' '</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #000088;">$xml</span> <span style="color: #339933;">.=</span> eZLoremIpsum<span style="color: #339933;">::</span><span style="color: #004000;">generateSentence</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #000088;">$xml</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;&lt;/paragraph&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #000088;">$xml</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot; &lt;/section&gt;<span style="color: #000099; font-weight: bold;">\n</span>&lt;/section&gt;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$attribute</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAttribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'data_text'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$xml</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'eztext'</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$numPars</span> <span style="color: #339933;">=</span> <a href="https://www.php.net/mt_rand"><span style="color: #990000;">mt_rand</span></a><span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span> int <span style="color: #009900;">&#41;</span> <span style="color: #000088;">$attributeparameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'min_pars'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span> int <span style="color: #009900;">&#41;</span> <span style="color: #000088;">$attributeparameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'max_pars'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$par</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$par</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$numPars</span><span style="color: #339933;">;</span> <span style="color: #000088;">$par</span><span style="color: #339933;">++</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$par</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$text</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$text</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #000088;">$numSentences</span> <span style="color: #339933;">=</span> <a href="https://www.php.net/mt_rand"><span style="color: #990000;">mt_rand</span></a><span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span> int <span style="color: #009900;">&#41;</span> <span style="color: #000088;">$attributeparameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'min_sentences'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span> int <span style="color: #009900;">&#41;</span> <span style="color: #000088;">$attributeparameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'max_sentences'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$sentence</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$sentence</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$numSentences</span><span style="color: #339933;">;</span> <span style="color: #000088;">$sentence</span><span style="color: #339933;">++</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$text</span> <span style="color: #339933;">.=</span> eZLoremIpsum<span style="color: #339933;">::</span><span style="color: #004000;">generateSentence</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #000088;">$text</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> &nbsp; <span style="color: #000088;">$attribute</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAttribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'data_text'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$text</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'ezboolean'</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$rnd</span> <span style="color: #339933;">=</span> <a href="https://www.php.net/mt_rand"><span style="color: #990000;">mt_rand</span></a><span style="color: #009900;">&#40;</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">99</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$value</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$rnd</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$attributeparameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'prob'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$value</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> &nbsp; <span style="color: #000088;">$attribute</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAttribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'data_int'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$value</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'ezinteger'</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$integer</span> <span style="color: #339933;">=</span> <a href="https://www.php.net/mt_rand"><span style="color: #990000;">mt_rand</span></a><span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span> int <span style="color: #009900;">&#41;</span> <span style="color: #000088;">$attributeparameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'min'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span> int <span style="color: #009900;">&#41;</span> <span style="color: #000088;">$attributeparameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'max'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$attribute</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAttribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'data_int'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$integer</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'ezfloat'</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$power</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">100</span><span style="color: #339933;">;</span> <span style="color: #000088;">$float</span> <span style="color: #339933;">=</span> <a href="https://www.php.net/mt_rand"><span style="color: #990000;">mt_rand</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$power</span> <span style="color: #339933;">*</span> <span style="color: #009900;">&#40;</span> int <span style="color: #009900;">&#41;</span> <span style="color: #000088;">$attributeparameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'min'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$power</span> <span style="color: #339933;">*</span> <span style="color: #009900;">&#40;</span> int <span style="color: #009900;">&#41;</span> <span style="color: #000088;">$attributeparameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'max'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$float</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$float</span> <span style="color: #339933;">/</span> <span style="color: #000088;">$power</span><span style="color: #339933;">;</span> <span style="color: #000088;">$attribute</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAttribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'data_float'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$float</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'ezprice'</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$power</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span> <span style="color: #000088;">$price</span> <span style="color: #339933;">=</span> <a href="https://www.php.net/mt_rand"><span style="color: #990000;">mt_rand</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$power</span> <span style="color: #339933;">*</span> <span style="color: #009900;">&#40;</span> int <span style="color: #009900;">&#41;</span> <span style="color: #000088;">$attributeparameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'min'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$power</span> <span style="color: #339933;">*</span> <span style="color: #009900;">&#40;</span> int <span style="color: #009900;">&#41;</span> <span style="color: #000088;">$attributeparameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'max'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$price</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$price</span> <span style="color: #339933;">/</span> <span style="color: #000088;">$power</span><span style="color: #339933;">;</span> <span style="color: #000088;">$attribute</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAttribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'data_float'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$price</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> &nbsp; <span style="color: #000088;">$attribute</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">store</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span> &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <a href="https://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$parameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'quick'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$parameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'quick'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$version</span> <span style="color: #339933;">=&amp;</span> <span style="color: #000088;">$object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">version</span><span style="color: #009900;">&#40;</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$version</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAttribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'status'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">3</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$version</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">store</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAttribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'status'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$objectName</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$class</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">contentObjectName</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$object</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setName</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$objectName</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAttribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'current_version'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$time</span> <span style="color: #339933;">=</span> <a href="https://www.php.net/mktime"><span style="color: #990000;">mktime</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAttribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'modified'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$time</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAttribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'published'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$time</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAttribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'section_id'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$sectionID</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">store</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$newNode</span> <span style="color: #339933;">=&amp;</span> <span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addChild</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$objectID</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">true</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$newNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAttribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'contentobject_version'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$newNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAttribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'contentobject_is_published'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$newNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setName</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$objectName</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$newNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAttribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'main_node_id'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$newNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'node_id'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$newNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAttribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'sort_field'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$nodeAssignment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'sort_field'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$newNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAttribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'sort_order'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$nodeAssignment</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'sort_order'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$newNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">updateSubTreePath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$newNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">store</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">commit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">commit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span>eZOperationHandler<span style="color: #339933;">::</span><span style="color: #004000;">execute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'content'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'publish'</span><span style="color: #339933;">,</span> <a href="https://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'object_id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$objectID</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'version'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">// TODO: </span> <span style="color: #666666; font-style: italic;">// add to the list of errors </span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">// TODO: </span> <span style="color: #666666; font-style: italic;">// add to the list of errors </span> <span style="color: #009900;">&#125;</span> &nbsp; <span style="color: #000088;">$parameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'structure'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$nodeID</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">--;</span> <span style="color: #000088;">$parameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'created_count'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">++;</span> &nbsp; <span style="color: #000088;">$bar</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">update</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$parameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'created_count'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span> &nbsp; &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <a href="https://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$parameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'quick'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$parameters</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'quick'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'kernel/classes/ezcontentcachemanager.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> eZContentCacheManager<span style="color: #339933;">::</span><span style="color: #004000;">clearAllContentCache</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> &nbsp; <span style="color: #000000; font-weight: bold;">function</span> cliGetLine<span style="color: #009900;">&#40;</span><span style="color: #000088;">$default</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #000088;">$input</span> <span style="color: #339933;">=</span> <a href="https://www.php.net/strtolower"><span style="color: #990000;">strtolower</span></a><span style="color: #009900;">&#40;</span><a href="https://www.php.net/trim"><span style="color: #990000;">trim</span></a><span style="color: #009900;">&#40;</span><a href="https://www.php.net/fgets"><span style="color: #990000;">fgets</span></a><span style="color: #009900;">&#40;</span>STDIN<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">return</span> <span style="color: #009900;">&#40;</span> <a href="https://www.php.net/strlen"><span style="color: #990000;">strlen</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$input</span><span style="color: #009900;">&#41;</span> ? <span style="color: #000088;">$input</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$default</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">////////////////////////// </span> <span style="color: #000088;">$script</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">shutdown</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000000; font-weight: bold;">?&gt;</span> &nbsp;</pre> Sun, 16 Aug 2009 12:35:22 GMT Hiding or unhiding subtrees https://ezpedia.org/snippets_for_ez_publish_3/hiding_or_unhiding_subtrees https://ezpedia.org/snippets_for_ez_publish_3/hiding_or_unhiding_subtrees <div class="object-right"><p class="version_info_ezp3">This is compatible with <a href="/es/ez/ez_publish_3" target="_self">eZ Publish 3</a>.</p></div><a name="eztoc383552_1" id="eztoc383552_1"></a><h2>Example code</h2> <pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'can_hide'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'is_hidden'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> eZContentObjectTreeNode<span style="color: #339933;">::</span><span style="color: #004000;">unhideSubTree</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$node</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span> eZContentObjectTreeNode<span style="color: #339933;">::</span><span style="color: #004000;">hideSubTree</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$node</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span></pre> Sun, 16 Aug 2009 12:35:21 GMT Fetching ezimage datatype image alias properties using PHP https://ezpedia.org/snippets_for_ez_publish_3/fetching_ezimage_datatype_image_alias_properties_using_php https://ezpedia.org/snippets_for_ez_publish_3/fetching_ezimage_datatype_image_alias_properties_using_php <div class="object-center"><p class="version_info_ezp3">This is compatible with <a href="/es/ez/ez_publish_3" target="_self">eZ Publish 3</a>.</p></div> <div class="object-center"> <p class="editor_motivation">This is a <a href="/es/template/stub">Stub</a> article. Help the eZ Publish community by expanding it!</p></div><a name="eztoc383536_1" id="eztoc383536_1"></a><h2>Introduction</h2><p>Did you know that you can use the eZ Publish kernel api to obtain image alias properties from content object attributes which use the ezimage datatype.</p><a name="eztoc383536_2" id="eztoc383536_2"></a><h2>Example</h2><p>This is a simple php example of how you may use the eZ Publish kernel api to obtain image alias properties. This example comes from a simple example custom module view.</p> <pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> &nbsp; <span style="color: #009933; font-style: italic;">/** * File image.php * * @package image.php * @version //autogentag// * @copyright Copyright (C) 2007 Brookins Consulting. All rights reserved. * @license https://www.gnu.org/licenses/gpl.txt GPL License */</span> &nbsp; <span style="color: #000088;">$Module</span> <span style="color: #339933;">=&amp;</span> <span style="color: #000088;">$Params</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Module'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #666666; font-style: italic;">// START</span> &nbsp; <span style="color: #666666; font-style: italic;">// Assume this type of module/view url:</span> <span style="color: #666666; font-style: italic;">// www.site.com/myextension/mymodule/myview/1234</span> <span style="color: #666666; font-style: italic;">// 1234 maps to the view parameter, MyNode (eg: $Params[&quot;MyNode&quot;])</span> &nbsp; <span style="color: #666666; font-style: italic;">// 0. Include the necessary files -- I would imagine that some are include</span> &nbsp; <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'lib/ezdb/classes/ezdb.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'lib/ezutils/classes/ezfunctionhandler.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'lib/ezutils/classes/ezoperationhandler.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'lib/ezutils/classes/ezhttptool.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'kernel/common/template.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'kernel/classes/ezcontentclass.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'kernel/classes/ezpreferences.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'kernel/classes/datatypes/ezimage/ezimage.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'kernel/classes/datatypes/ezurl/ezurl.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'kernel/classes/datatypes/ezurl/ezurlobjectlink.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #666666; font-style: italic;">// 1. Create an instance of the database</span> <span style="color: #000088;">$db</span> <span style="color: #339933;">=&amp;</span> eZDB<span style="color: #339933;">::</span><span style="color: #004000;">instance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #666666; font-style: italic;">// 2. Query the node via node id</span> <span style="color: #000088;">$my_node</span> <span style="color: #339933;">=&amp;</span> eZContentObject<span style="color: #339933;">::</span><span style="color: #004000;">fetchByNodeID</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$Params</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;MyNode&quot;</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// $my_node =&amp; eZContentObject::fetchByNodeID( '86' );</span> &nbsp; <span style="color: #666666; font-style: italic;">// 3. Get a copy of the data_map</span> <span style="color: #000088;">$my_node_data_map</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$my_node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetchDataMap</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #666666; font-style: italic;">// 4. Get a reference to the image</span> <span style="color: #000088;">$my_node_image</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$my_node_data_map</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;image&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// $my_node_image_data = $my_node_image-&gt;DataText;</span> &nbsp; <span style="color: #666666; font-style: italic;">// Example Usage of the eZ Image Alias Handler Class / System</span> <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'kernel/classes/datatypes/ezimage/ezimagealiashandler.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #666666; font-style: italic;">// 5. Fetch Alias Handler</span> <span style="color: #000088;">$image_alias_handler</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> eZImageAliasHandler<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$my_node_image</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #666666; font-style: italic;">// 6. Fetch Alias Attributes*</span> &nbsp; <span style="color: #666666; font-style: italic;">// 7. Fetch Original Image Path as URI</span> <span style="color: #000088;">$my_node_image_uri</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;/&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$image_alias_handler</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attributeFromOriginal</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'url'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #666666; font-style: italic;">// 8. Fetch Original Image Dimentions</span> <span style="color: #000088;">$my_node_image_width</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$image_alias_handler</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attributeFromOriginal</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'width'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$my_node_image_height</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$image_alias_handler</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attributeFromOriginal</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'height'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #666666; font-style: italic;">// 9. Get the associated link</span> <span style="color: #000088;">$my_node_link_object</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$my_node_data_map</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;my_link&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$my_node_link_url_object</span> <span style="color: #339933;">=</span> eZURL<span style="color: #339933;">::</span><span style="color: #004000;">fetch</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$my_node_link_object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">DataInt</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$my_node_link_url</span><span style="color: #339933;">=</span><a href="https://www.php.net/str_replace"><span style="color: #990000;">str_replace</span></a> <span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;+&quot;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$my_node_link_url_object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'url'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #666666; font-style: italic;">// 10. Instantiate the template and set the template vars</span> <span style="color: #000088;">$tpl</span> <span style="color: #339933;">=&amp;</span> templateInit<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$tpl</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setVariable</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'parameters'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$Params</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$tpl</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setVariable</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'my_node_image_path'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$my_node_image_uri</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$tpl</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setVariable</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'my_node_image_width'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$my_node_image_width</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$tpl</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setVariable</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'my_node_image_height'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$my_node_image_height</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$tpl</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setVariable</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'my_node_link_url'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$my_node_link_url</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #666666; font-style: italic;">// END</span> &nbsp; <span style="color: #666666; font-style: italic;">// phpinfo();</span> eZExecution<span style="color: #339933;">::</span><span style="color: #004000;">cleanExit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000000; font-weight: bold;">?&gt;</span></pre><a name="eztoc383536_3" id="eztoc383536_3"></a><h2>References</h2> <ul> <li><a href="/es/ez/image_alias_handler" target="_self">ezimagealiashandler</a></li> </ul> Sun, 16 Aug 2009 12:35:20 GMT In-memory object cache https://ezpedia.org/snippets_for_ez_publish_3/in_memory_object_cache https://ezpedia.org/snippets_for_ez_publish_3/in_memory_object_cache <div class="object-center"><p class="version_info_ezp3">This is compatible with <a href="/es/ez/ez_publish_3" target="_self">eZ Publish 3</a>.</p></div><a name="eztoc383508_1" id="eztoc383508_1"></a><h2>Clearing the cache</h2><p>When looping over a big amount of content objects or tree nodes, fetch them in cycles of 100 or less and after each cycle, clear the in-memory object cache:</p> <pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'kernel/classes/ezcontentobject.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> eZContentObject<span style="color: #339933;">::</span><span style="color: #004000;">clearCache</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre><a name="eztoc383508_2" id="eztoc383508_2"></a><h2>External resources</h2> <ul> <li><a href="https://ez.no/community/bugs/memory_leak_in_updatemultilingual_php" target="_self">Bug: memory leakage in updatemultilingual.php</a></li> </ul> Sun, 16 Aug 2009 12:35:19 GMT Creating new content object versions with PHP https://ezpedia.org/snippets_for_ez_publish_3/creating_new_content_object_versions_with_php https://ezpedia.org/snippets_for_ez_publish_3/creating_new_content_object_versions_with_php <div class="object-right"><p class="version_info_ezp3">This is compatible with <a href="/es/ez/ez_publish_3" target="_self">eZ Publish 3</a>.</p></div><p>You can update objects by creating new version and publish the new version.</p><a name="eztoc383528_0_1" id="eztoc383528_0_1"></a><h3>The code</h3><a name="eztoc383528_0_2" id="eztoc383528_0_2"></a><h3>Known variables</h3> <ul> <li>$object, instance of class eZContentObject</li> </ul> <a name="eztoc383528_0_3" id="eztoc383528_0_3"></a><h3>Sample</h3> <pre class="php" style="font-family:monospace;"><span style="color: #000088;">$newVersion</span> <span style="color: #339933;">=&amp;</span> <span style="color: #000088;">$object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">createNewVersion</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$newData</span> <span style="color: #339933;">=&amp;</span> <span style="color: #000088;">$object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">fetchDataMap</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$newVersion</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'version'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #666666; font-style: italic;">// change attributes of new version here, by using $newData data map</span> &nbsp; <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'lib/ezutils/classes/ezoperationhandler.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> eZOperationHandler<span style="color: #339933;">::</span><span style="color: #004000;">execute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'content'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'publish'</span><span style="color: #339933;">,</span> <a href="https://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'object_id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'id'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'version'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$newVersion</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'version'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp;</pre> Sun, 16 Aug 2009 12:35:19 GMT Logging in a specific user https://ezpedia.org/snippets_for_ez_publish_3/logging_in_a_specific_user https://ezpedia.org/snippets_for_ez_publish_3/logging_in_a_specific_user <div class="object-right"><p class="version_info_ezp3">This is compatible with <a href="/es/ez/ez_publish_3" target="_self">eZ Publish 3</a>.</p></div><a name="eztoc383468_1" id="eztoc383468_1"></a><h2>Code sample</h2><p>The following code will login the user with the login specified by <i>$login</i>. It is especially useful in cronjob scripts when you need sufficient privileges.</p> <pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'kernel/classes/datatypes/ezuser/ezuser.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$user</span> <span style="color: #339933;">=</span> eZUser<span style="color: #339933;">::</span><span style="color: #004000;">fetchByName</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$login</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$userID</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'contentobject_id'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> eZUser<span style="color: #339933;">::</span><span style="color: #004000;">setCurrentlyLoggedInUser</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$user</span><span style="color: #339933;">,</span> <span style="color: #000088;">$userID</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre><a name="eztoc383468_2" id="eztoc383468_2"></a><h2>Compatibility</h2><p>In all recent versions of eZ publish the content/read policy limitation list of the current user gets cached in a global array by eZContentObjectTreeNode. When switching users, this cache isn't cleared. This issue has been reported as <a href="https://ez.no/community/bugs/cache_for_content_read_limitation_list_isn_t_cleared_after_switching_users" target="_self">bug 8388 at ez.no</a>.</p><p>You can workaround this problem by clearing the cache yourself with the following code:</p> <pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <a href="https://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'ezpolicylimitation_list'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'content'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'read'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <a href="https://www.php.net/unset"><span style="color: #990000;">unset</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$GLOBALS</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'ezpolicylimitation_list'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'content'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'read'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span></pre> Sun, 16 Aug 2009 12:35:16 GMT Adding additional locations for an object https://ezpedia.org/snippets_for_ez_publish_3/adding_additional_locations_for_an_object https://ezpedia.org/snippets_for_ez_publish_3/adding_additional_locations_for_an_object <div class="object-right"><p class="version_info_ezp3">This is compatible with <a href="/es/ez/ez_publish_3" target="_self">eZ Publish 3</a>.</p></div><a name="eztoc383436_1" id="eztoc383436_1"></a><h2>Compatibility</h2><p>The code above works with eZ publish <a href="/es/ez/ez_publish_3_8" target="_self">3.8</a> and <a href="/es/ez/ez_publish_3_9" target="_self">3.9</a>.</p><a name="eztoc383436_2" id="eztoc383436_2"></a><h2>Policy checking</h2><p>You can remove policy checking by removing the conditional structures with $canManageLocations and $canCreate</p><a name="eztoc383436_3" id="eztoc383436_3"></a><h2>Code sample</h2><p>Since eZ publish 3.8, the publish operation doesn't need to be executed anymore when adding new locations for objects which are already in the node tree.</p><p>The following code was based on a part of the action view of the content module (kernel/content/action.php). The known variables are:</p> <ul> <li>$node: instance of eZContentObjectTreeNode, which holds the object we want to create new tree leaves for</li> <li>$selectedNodeIDArray: array with the node ID's of the additional parent nodes</li> </ul> <pre class="php" style="font-family:monospace;"><span style="color: #000088;">$object</span> <span style="color: #339933;">=&amp;</span> <span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'object'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$objectID</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'id'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'kernel/classes/datatypes/ezuser/ezuser.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$user</span> <span style="color: #339933;">=&amp;</span> eZUser<span style="color: #339933;">::</span><span style="color: #004000;">currentUser</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$canManageLocations</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">checkAccess</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'edit'</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'has_manage_locations'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$canManageLocations</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> &nbsp; <span style="color: #000088;">$nodeAssignmentList</span> <span style="color: #339933;">=</span> eZNodeAssignment<span style="color: #339933;">::</span><span style="color: #004000;">fetchForObject</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$objectID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'current_version'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">false</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$assignedNodes</span> <span style="color: #339933;">=&amp;</span> <span style="color: #000088;">$object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">assignedNodes</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$objectID</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'id'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$parentNodeIDArray</span> <span style="color: #339933;">=</span> <a href="https://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$setMainNode</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #339933;">;</span> <span style="color: #000088;">$hasMainNode</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$assignedNodes</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$assignedNode</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$assignedNodeID</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$assignedNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'node_id'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$assignedNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'is_main'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$hasMainNode</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> &nbsp; <span style="color: #000088;">$append</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$nodeAssignmentList</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$nodeAssignment</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$nodeAssignment</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'parent_node'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$assignedNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'parent_node_id'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$append</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$append</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$parentNodeIDArray</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$assignedNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'parent_node_id'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span> &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #000088;">$hasMainNode</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$setMainNode</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> &nbsp; <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'lib/ezdb/classes/ezdb.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$db</span> <span style="color: #339933;">=&amp;</span> eZDB<span style="color: #339933;">::</span><span style="color: #004000;">instance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">begin</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$locationAdded</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">false</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$selectedNodeIDArray</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$selectedNodeID</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><a href="https://www.php.net/in_array"><span style="color: #990000;">in_array</span></a><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$selectedNodeID</span><span style="color: #339933;">,</span> <span style="color: #000088;">$parentNodeIDArray</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$parentNode</span> <span style="color: #339933;">=</span> eZContentObjectTreeNode<span style="color: #339933;">::</span><span style="color: #004000;">fetch</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$selectedNodeID</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$parentNodeObject</span> <span style="color: #339933;">=&amp;</span> <span style="color: #000088;">$parentNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'object'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$canCreate</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$parentNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">checkAccess</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'create'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'contentclass_id'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$parentNodeObject</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'contentclass_id'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$parentNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">canAddLocation</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">canRead</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$canCreate</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$insertedNode</span> <span style="color: #339933;">=&amp;</span> <span style="color: #000088;">$object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addLocation</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$selectedNodeID</span><span style="color: #339933;">,</span> <span style="color: #000000; font-weight: bold;">true</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #666666; font-style: italic;">// Now set is as published and fix main_node_id</span> <span style="color: #000088;">$insertedNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAttribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'contentobject_is_published'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$insertedNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAttribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'main_node_id'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'main_node_id'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$insertedNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAttribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'contentobject_version'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'contentobject_version'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Make sure the path_identification_string is set correctly.</span> <span style="color: #000088;">$insertedNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">updateSubTreePath</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$insertedNode</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">sync</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$locationAdded</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span> &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$locationAdded</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'lib/ezutils/classes/ezini.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$ini</span> <span style="color: #339933;">=&amp;</span> eZINI<span style="color: #339933;">::</span><span style="color: #004000;">instance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$userClassID</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$ini</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">variable</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">&quot;UserSettings&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;UserClassID&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000088;">$object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attribute</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'contentclass_id'</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$userClassID</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> eZUser<span style="color: #339933;">::</span><span style="color: #004000;">cleanupCache</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span> <span style="color: #000088;">$db</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">commit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">include_once</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'kernel/classes/ezcontentcachemanager.php'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> eZContentCacheManager<span style="color: #339933;">::</span><span style="color: #004000;">clearContentCacheIfNeeded</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$objectID</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span></pre> Sun, 16 Aug 2009 12:35:14 GMT API code samples https://ezpedia.org/snippets_for_ez_publish_3/api_code_samples https://ezpedia.org/snippets_for_ez_publish_3/api_code_samples <div class="object-center"> <p class="editor_motivation">This is a <a href="/es/template/stub">Stub</a> article. Help the eZ Publish community by expanding it!</p></div> <p>This page will give you an overview of code samples which demonstrate how to use the eZ publish <a href="https://en.wikipedia.org/wiki/Application_programming_interface" target="_self">API</a>.</p> <a name="eztoc383416_1" id="eztoc383416_1"></a><h2>Content</h2> <a name="eztoc383416_1_1" id="eztoc383416_1_1"></a><h3>Objects and the node tree</h3> <a name="eztoc383416_1_1_1" id="eztoc383416_1_1_1"></a><h4>Fetching data</h4> <ul> <li> <a href="/es/snippets_for_ez_publish_3/in_memory_object_cache" target="_self">avoiding memory exhaustion</a> </li> <li> <a href="/es/snippet/template_logic_to_display_fetched_parent_content_object_name" target="_self">display fetched parent name</a> </li> <li> <a href="https://ez.no/community/forum/developer/how_to_do_a_fetch_with_php" target="_self">how to do a fetch with php</a> </li> <li> <a href="https://ez.no/community/forum/developer/how_to_update_an_attribute_of_an_object_with_php" target="_self">how to update an attribute of an object with php</a> </li> <li> <a href="https://ez.no/community/forum/developer/get_the_image_storage_path_from_a_contentobjectid_php_side" target="_self">get the image storage path from a ContentObjectID</a> </li> <li> <a href="https://ez.no/community/forum/general/fetching_user_data" target="_self">fetching user data</a> </li> <li> <a href="https://ez.no/community/forum/developer/how_to_fetch_class_objects_in_php" target="_self">how to fetch class objects in php</a> </li> </ul> <a name="eztoc383416_1_1_2" id="eztoc383416_1_1_2"></a><h4>Manipulating data </h4> <ul> <li> <a href="/es/snippets_for_ez_publish_3/creating_new_content_objects_with_php" target="_self">creating new objects</a> </li> <li> putting data into attributes </li> <li> adding relations </li> <li> placing objects in the node tree </li> <li> <a href="/es/snippets_for_ez_publish_3/adding_additional_locations_for_an_object" target="_self">placing objects at additional locations</a> </li> <li> updating objects = <a href="/es/snippets_for_ez_publish_3/creating_new_content_object_versions_with_php" target="_self">creating new content object versions</a> </li> <li> removing objects </li> <li> <a href="/es/snippets_for_ez_publish_3/moving_a_node" target="_self">moving nodes</a> </li> <li> <a href="/es/snippets_for_ez_publish_3/hiding_or_unhiding_subtrees" target="_self">hiding and unhiding subtrees</a> </li> <li> <a href="/es/snippets_for_ez_publish_3/copying_objects" target="_self">copying objects</a> </li> <li> <a href="/es/snippets_for_ez_publish_3/assigning_sections" target="_self">assigning sections</a> </li> <li> changing object ownership </li> </ul> <a name="eztoc383416_1_2" id="eztoc383416_1_2"></a><h3>Classes</h3> <ul> <li> adding class attributes </li> <li> reordering class attributes </li> </ul> <a name="eztoc383416_1_3" id="eztoc383416_1_3"></a><h3>Charsets</h3> <ul> <li> converting external data to the internal charset </li> </ul> <a name="eztoc383416_1_4" id="eztoc383416_1_4"></a><h3>Notifications</h3> <ul> <li> <a href="/es/snippets_for_ez_publish_3/adding_subtree_notification_rules" target="_self">adding subtree notification rules</a> </li> <li> removing subtree notification rules </li> <li> <a href="/es/snippets_for_ez_publish_3/adding_collaboration_notification_rules" target="_self">adding collaboration notifications rules</a> </li> <li> removing collaboration notification rules </li> </ul> <a name="eztoc383416_2" id="eztoc383416_2"></a><h2>Users</h2> <a name="eztoc383416_2_5" id="eztoc383416_2_5"></a><h3>Authentication</h3> <ul> <li> <a href="/es/snippets_for_ez_publish_3/logging_in_a_specific_user" target="_self">logging in a specific user</a> </li> <li> <a href="/es/solution/how_to_provide_for_intranet_ip_based_authentication" target="_self">ip based authentication</a> </li> <li> authenticate with login handlers </li> </ul> <a name="eztoc383416_2_6" id="eztoc383416_2_6"></a><h3>Roles</h3> <ul> <li> <a href="/es/snippets_for_ez_publish_3/assigning_roles" target="_self">assigning roles</a> </li> </ul> <a name="eztoc383416_2_7" id="eztoc383416_2_7"></a><h3>Preferences</h3> <ul> <li> setting user preferences </li> <li> removing user preferences </li> </ul> Sun, 16 Aug 2009 12:35:13 GMT Template operator to strip strings for tags https://ezpedia.org/snippet/template_operator_to_strip_strings_for_tags https://ezpedia.org/snippet/template_operator_to_strip_strings_for_tags <a name="eztoc42241_1" id="eztoc42241_1"></a><h2>Question</h2> <pre class="eztemplate" style="font-family:monospace;">&lt;Tidemann&gt; is there an operator that strips a string for tags? &lt;Tidemann&gt; ...or removes images from an ezxml output</pre><a name="eztoc42241_2" id="eztoc42241_2"></a><h2>Solution</h2> <pre class="eztemplate" style="font-family:monospace;">&lt;Bratt&gt; No, but you can make one really simple &lt;Bratt&gt; ...by using simpletags() &lt;Bratt&gt; Set up this in template.ini: [SimpleTagsOperator], TagList_NoTags[], TagList_NoTags[text]=;;strip_tags &lt;Bratt&gt; Then you can use simpletags( 'NoTags' ) &lt;Tidemann&gt; Bratt: hmm.. nice... haven't seen simpletags before actually &lt;Tidemann&gt; Bratt: can I use the method here to enable a-tags too then? https://ez.no/community/forum/setup_design/text_block_vs_xml_block_in_forum_topic_tpl/re_text_block_vs_xml_block_q__4 &lt;Bratt&gt; Sure, just set it up in template.ini &lt;Tidemann&gt; cool! thanx! &lt;kracker&gt; wow, i wish you would write that into eZpedia ... &lt;Bratt&gt; Yes, I know. Took some time before I realized how simple it could be done &lt;zurgutt&gt; interesting &lt;Tidemann&gt; Bratt: uhm.. TagList_NoTags[text]=;;strip_tags seems to remove everything &lt;Tidemann&gt; <span style="color: #66cc66;">&#123;</span><span style="color: #0000bb;">$child</span>.<span style="color: #006600;">data_map</span>.<span style="color: #006600;">intro</span>.<span style="color: #006600;">content</span><span style="color: #66cc66;">|</span>simpletags<span style="color: #66cc66;">&#40;</span><span style="color: #dd0000;">'NoTags'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#125;</span> &lt;-- right? &lt;Bratt&gt; Tidemann: Yes, that was the point. If you want to keep a-tags, you need to set that up in template.ini &lt;Bratt&gt; Add a line something like: TagList_NoTags[text]=&lt;a&gt;;&lt;/a&gt;;strip_tags &lt;Bratt&gt; But I would call it something other than NoTags then &lt;Bratt&gt; KeepLinks, or whatever &lt;Tidemann&gt; Bratt: I didn't realise it removed the content of the tag aswell... &lt;Bratt&gt; Tidemann: A tag includes the content of it :) &lt;Tidemann&gt; Bratt: hehe.. &nbsp;</pre><a name="eztoc42241_3" id="eztoc42241_3"></a><h2>External reference</h2> <ul> <li>Forum: <a href="https://ez.no/community/forum/setup_design/text_block_vs_xml_block_in_forum_topic_tpl/re_text_block_vs_xml_block_q__4" target="_self">Text block vs xml block</a> </li> </ul> Sun, 09 Aug 2009 02:51:32 GMT Template logic to test object attribute https://ezpedia.org/snippet/template_logic_to_test_object_attribute https://ezpedia.org/snippet/template_logic_to_test_object_attribute <div class="object-center"> <p class="editor_motivation">This is a <a href="/es/template/stub">Stub</a> article. Help the eZ Publish community by expanding it!</p></div><a name="eztoc14518_1" id="eztoc14518_1"></a><h2>Example</h2><p>You can use this as a simple solution</p> <pre class="eztemplate" style="font-family:monospace;"><span style="color: #66cc66;">&#123;</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=if&SearchContentClassID=23"><span style="color: #0600FF;">if</span></a> <span style="color: #0000bb;">$attribute</span>.<span style="color: #006600;">content</span>.<span style="color: #006600;">filename</span><span style="color: #66cc66;">&#125;</span> <span style="color: #808080; font-style: italic;">{* show the player *}</span> ... <span style="color: #66cc66;">&#123;</span>else<span style="color: #66cc66;">&#125;</span> &nbsp; <span style="color: #808080; font-style: italic;">{* omit the player *}</span> ... <span style="color: #66cc66;">&#123;</span><span style="color: #66cc66;">/</span><a href="https://ez.no/doc/content/advancedsearch?SearchText=if&SearchContentClassID=23"><span style="color: #0600FF;">if</span></a><span style="color: #66cc66;">&#125;</span> </pre><a name="eztoc14518_1_1" id="eztoc14518_1_1"></a><h3>Reference</h3> <ul> <li>Forum: <a href="https://ez.no/community/forum/general/how_to_test_an_media_attribute" target="_self">How to test an media attribute</a> </li> </ul> Sun, 09 Aug 2009 02:48:04 GMT