Skip to content

Instantly share code, notes, and snippets.

@idokd
Last active February 9, 2022 14:08
Show Gist options
  • Select an option

  • Save idokd/0dde8ee2a2fe2685c30c86e0188fb5c8 to your computer and use it in GitHub Desktop.

Select an option

Save idokd/0dde8ee2a2fe2685c30c86e0188fb5c8 to your computer and use it in GitHub Desktop.
vtiger view actions with dropdown options - childLinks
$link = [
'linktype' => 'DETAILVIEWBASIC',
'linklabel' => vtranslate( 'Parent Button Label' )
];
$link = Vtiger_Link_Model::getInstanceFromValues( $link );
$link->addChildLink( Vtiger_Link_Model::getInstanceFromValues( [
'linklabel' => vtranslate( 'Child Link Label' ),
'linkurl' => '?url_to_go_to'
] ) );
{foreach item=DETAIL_VIEW_BASIC_LINK from=$DETAILVIEW_LINKS['DETAILVIEWBASIC']}
{assign var=childLinks value=$DETAIL_VIEW_BASIC_LINK->getChildLinks()}
{assign var=dropbox value=($childLinks|@count gt 0)}
{if !$dropbox}
<button class="btn btn-default" id="{$MODULE_NAME}_detailView_basicAction_{Vtiger_Util_Helper::replaceSpaceWithUnderScores($DETAIL_VIEW_BASIC_LINK->getLabel())}"
{if $DETAIL_VIEW_BASIC_LINK->isPageLoadLink()}
onclick="window.location.href = '{$DETAIL_VIEW_BASIC_LINK->getUrl()}&app={$SELECTED_MENU_CATEGORY}'"
{else}
onclick="{$DETAIL_VIEW_BASIC_LINK->getUrl()}"
{/if}
{if $MODULE_NAME eq 'Documents' && $DETAIL_VIEW_BASIC_LINK->getLabel() eq 'LBL_VIEW_FILE'}
data-filelocationtype="{$DETAIL_VIEW_BASIC_LINK->get('filelocationtype')}" data-filename="{$DETAIL_VIEW_BASIC_LINK->get('filename')}"
{/if}>
{vtranslate($DETAIL_VIEW_BASIC_LINK->getLabel(), $MODULE_NAME)}
</button>
{else}<span>
<button class="btn btn-default dropdown-toggle" data-toggle="dropdown" href="javascript:void(0);">
{vtranslate($DETAIL_VIEW_BASIC_LINK->getLabel(), $MODULE_NAME)}&nbsp;&nbsp;<i class="caret"></i>
</button>
<ul class="dropdown-menu dropdown-menu-right">
{foreach item=DETAIL_VIEW_LINK from=$childLinks}
{if $DETAIL_VIEW_LINK->getLabel() eq ""}
<li class="divider"></li>
{else}
<li id="{$MODULE_NAME}_detailView_moreAction_{Vtiger_Util_Helper::replaceSpaceWithUnderScores($DETAIL_VIEW_LINK->getLabel())}">
{if $DETAIL_VIEW_LINK->getUrl()|strstr:"javascript"}
<a href='{$DETAIL_VIEW_LINK->getUrl()}'>{vtranslate($DETAIL_VIEW_LINK->getLabel(), $MODULE_NAME)}</a>
{else}
<a href='{$DETAIL_VIEW_LINK->getUrl()}&app={$SELECTED_MENU_CATEGORY}' >{vtranslate($DETAIL_VIEW_LINK->getLabel(), $MODULE_NAME)}</a>
{/if}
</li>
{/if}
{/foreach}
</ul>
</span>
{/if}
{/foreach}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment