<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>blog.joaomorais.com &#187; Views</title>
	<atom:link href="http://blog.joaomorais.com/tag/views/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.joaomorais.com</link>
	<description>Blog about software development, personal projects and development tools.</description>
	<lastBuildDate>Mon, 10 Apr 2017 02:26:40 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>How to force a view to load other modules languages into SUGAR.language?</title>
		<link>http://blog.joaomorais.com/how-to-force-a-view-to-load-other-modules-languages-into-sugar-language/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-force-a-view-to-load-other-modules-languages-into-sugar-language</link>
		<comments>http://blog.joaomorais.com/how-to-force-a-view-to-load-other-modules-languages-into-sugar-language/#comments</comments>
		<pubDate>Sat, 26 May 2012 18:27:33 +0000</pubDate>
		<dc:creator>João Morais</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Papers]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[SugarCRM]]></category>
		<category><![CDATA[SugarCRM 6.x]]></category>
		<category><![CDATA[Views]]></category>

		<guid isPermaLink="false">http://blog.joaomorais.com/?p=1030</guid>
		<description><![CDATA[As you should know each SugarCRM view extends SugarView class which has a nifty method called _displayJavascript()  who is responsible for including all needed JavaScript files. When it comes to labels, by default, this function only loads current module labels into SUGAR.language. These labels are acessible through the following command: SUGAR.language.get('&#60;ModuleName&#62;', 'LBL_&#60;LabelName&#62;'); In order to add [...]]]></description>
				<content:encoded><![CDATA[<p><img class="alignright  wp-image-1026" title="SugarCRM" alt="SugarCRM" src="http://blog.joaomorais.com/wp-content/uploads/2012/05/sugarCRM-logo.jpg" width="229" height="110" />As you should know each <a title="SugarCRM" href="http://www.sugarcrm.com/" target="_blank">SugarCRM</a> view extends SugarView class which has a nifty method called _displayJavascript()  who is responsible for including all needed JavaScript files.</p>
<p>When it comes to labels, by default, this function only loads current module labels into SUGAR.language.</p>
<p><span id="more-1030"></span>These labels are acessible through the following command:</p>
<pre class="brush:js">SUGAR.language.get('&lt;ModuleName&gt;', 'LBL_&lt;LabelName&gt;');</pre>
<p>In order to add support to other module labels to be included, you should override _displayJavascript() method in your modules view, and specify which other modules labels should be included.</p>
<pre class="brush:php">// modules/&lt;ModuleName&gt;/views/view.edit.php

require_once 'include/MVC/View/views/view.edit.php';

class &lt;ModuleName&gt;ViewEdit extends ViewEdit
{
    protected function _displayJavascript()
    {
        parent::_displayJavascript();

        if (!$this-&gt;_getOption('show_javascript')) {
            return;
        }

        $modules = array(
            '&lt;Module1Name&gt;',
            '&lt;Module2Name&gt;',
        );

        foreach ($modules as $module) {
            if (!is_file($GLOBALS['sugar_config']['cache_dir'] . 'jsLanguage/' . $module . '/' . $GLOBALS['current_language'] . '.js')) {
                require_once 'include/language/jsLanguage.php';
                jsLanguage::createModuleStringsCache($module, $GLOBALS['current_language']);
            }
            echo '&lt;script type="text/javascript" src="' . $GLOBALS['sugar_config']['cache_dir'] . 'jsLanguage/' . $module . '/' . $GLOBALS['current_language'] . '.js?s=' . $GLOBALS['js_version_key'] . '&amp;c=' . $GLOBALS['sugar_config']['js_custom_version'] . '&amp;j=' . $GLOBALS['sugar_config']['js_lang_version'] . '"&gt;&lt;/script&gt;';
        }
    }
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.joaomorais.com/how-to-force-a-view-to-load-other-modules-languages-into-sugar-language/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to reset field values on bean duplication?</title>
		<link>http://blog.joaomorais.com/how-to-reset-field-values-on-bean-duplication/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=how-to-reset-field-values-on-bean-duplication</link>
		<comments>http://blog.joaomorais.com/how-to-reset-field-values-on-bean-duplication/#comments</comments>
		<pubDate>Sat, 26 May 2012 17:58:14 +0000</pubDate>
		<dc:creator>João Morais</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Papers]]></category>
		<category><![CDATA[Bean]]></category>
		<category><![CDATA[SugarCRM]]></category>
		<category><![CDATA[SugarCRM 6.x]]></category>
		<category><![CDATA[Views]]></category>

		<guid isPermaLink="false">http://blog.joaomorais.com/?p=1008</guid>
		<description><![CDATA[What you need to do is inject some logic to clear selected field values before the view is displayed. Like all other stuff made in SugarCRM, this process also depends on what type of module you&#8217;re hacking, in other words, the place where you&#8217;re going to write the logic depends if you&#8217;re hacking a custom [...]]]></description>
				<content:encoded><![CDATA[<p><img class="alignright  wp-image-1026" title="SugarCRM" alt="SugarCRM" src="http://blog.joaomorais.com/wp-content/uploads/2012/05/sugarCRM-logo.jpg" width="229" height="110" />What you need to do is inject some logic to clear selected field values before the view is displayed.</p>
<p>Like all other stuff made in <a title="SugarCRM" href="http://www.sugarcrm.com/" target="_blank">SugarCRM</a>, this process also depends on what type of module you&#8217;re hacking, in other words, the place where you&#8217;re going to write the logic depends if you&#8217;re hacking a custom module or a core one.</p>
<p><span id="more-1008"></span>Before you perform view customizations on core modules you should check first if the view is already implemented, in this case, you should check if the following file exists:</p>
<pre class="brush:shell">modules/&lt;ModuleName&gt;/views/view.edit.php</pre>
<p>If so, you should create a new file on:</p>
<pre class="brush:shell">custom/modules/&lt;ModuleName&gt;/views/view.edit.php</pre>
<p>and add further customizations.</p>
<p>Beware that on latest <a title="SugarCRM" href="http://www.sugarcrm.com/" target="_blank">SugarCRM</a> versions, you&#8217;re able to create custom views without having to copy all the logic from the core ones, and by that I mean that now you&#8217;re able to &#8220;truly&#8221; extend the custom views from the latter.</p>
<p>In order to achieve this the view name should be prefixed with &#8216;Custom&#8217;:</p>
<div>
<pre class="brush:php">// custom/modules/&lt;ModuleName&gt;/views/view.edit.php

require_once 'modules/&lt;ModuleName&gt;/views/view.edit.php

class Custom&lt;ModuleName&gt;ViewEdit extends &lt;ModuleName&gt;ViewEdit {
    /** 
     * ...
     */
}</pre>
</div>
<p>If by instance you&#8217;re hacking a core module that doesn&#8217;t have the view defined, you should create it like the example above but with a few differences:</p>
<pre class="brush:php">// custom/modules/&lt;ModuleName&gt;/views/view.edit.php

require_once 'include/MVC/View/views/view.edit.php';

class Custom&lt;ModuleName&gt;ViewEdit extends ViewEdit {
    /** 
     * ...
     */
}</pre>
<p>One thing to keep in mind is that if you&#8217;re hacking a custom module, you are able to choose which directory suits you best. As opposite to the examples above, on the example below, the logic is written directly on the module main folder.</p>
<pre class="brush:php">// modules/&lt;ModuleName&gt;/views/view.edit.php

require_once 'include/MVC/View/views/view.edit.php';

class &lt;ModuleName&gt;ViewEdit extends ViewEdit
{
    public function display()
    {
        $this-&gt;_processDuplicate();
        parent::display();
    }

    /**
     * How bean will act on edit view when it's being duplicated.
     */
    protected function _processDuplicate()
    {
        if ($this-&gt;ev-&gt;isDuplicate) {
            $this-&gt;bean-&gt;&lt;FieldName&gt; = '';
        }
    }
}</pre>
<p>Thanks to Jeff Bickart of <a title="Nepo Systems" href="http://www.neposystems.com/" target="_blank">Nepo Systems</a> and Matthew Poer of <a title="Profiling Solutions" href="http://www.profilingsolutions.com" target="_blank">Profiling Solutions</a> for pointing the &#8220;truly&#8221; Custom views feature out.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.joaomorais.com/how-to-reset-field-values-on-bean-duplication/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
