Page 1 of 1

Menu based on cssmenu

Posted: Fri Apr 17, 2020 3:05 am
by TPrigas
Hello!

I've customized a Menu from cssmenu. It looks fine in the page and on hover the target shows up in the status bar of the browser. But when I click a link nothing happens. Other links out of the menu are working. Here is the code:

Code: Select all

{* Ormed Menu *}
{* this template uses recursion, but not a smarty function. *}
{*
  variables:
  node: contains the current node.
  aclass: is used to build a string containing class names given to the a tag if one is used
  liclass: is used to build a string containing class names given to the li tag.
*}
{if !isset($depth)}{$depth=0}{/if}
{strip}

{if $depth == 0}
    <nav class="nav-menu d-none d-lg-block">
    <!--main-nav-start-->
	<ul class="nav-inner">
	{else}
    <ul>
{/if}

{$depth=$depth+1}
{foreach $nodes as $node}
  {* setup classes for the anchor and list item *}
  {$liclass=[]}
  {$aclass=[]}

  {* the first child gets a special class *}
  {*if $node@first && $node@total > 1}{$liclass[]='first_child'}{/if*}

  {* the last child gets a special class *}
  {*if $node@last && $node@total > 1}{$liclass[]='last_child'}{/if*}

  {if $node->current}
    {* this is the current page *}
    {*$liclass[]="menuactive active"*}
    {$liclass[]="active"}
    {*$aclass[]="menuactive"*}
  {/if}
  {if $node->has_children}
    {* this is a parent page *}
    {*$liclass[]="menuparent drop-down"*}
    {$liclass[]="drop-down"}
    {*$aclass[]="menuparent"*}
  {/if}

  {if $depth == 1 && $node@iteration == 5}
    <li class="nav-logo">
      <a href="https://ordemdosmedicos.co.ao">
        <img src="{uploads_url}/images/logo.svg" alt="Ordem dos Médicos de Angola" width="55px" alt="" class="img-fluid" />
      </a>
    </li>{*else*}{*$node->menutext*}
  {/if}

  {* build the menu item from the node *}
  {if $node->type == 'sectionheader'}
    <li class='{implode(' ',$liclass)}'><a{if count($aclass) > 0} class="{implode(' ',$aclass)}"{/if}><span class="sectionheader">{$node->menutext}</span></a>
      {if isset($node->children)}
        {include file=$smarty.template nodes=$node->children}
      {/if}
    </li>
  {else if $node->type == 'separator'}
    <li style="list-style-type: none;"><hr class="menu_separator"/></li>
  {else}
    {* regular item *}
    <li class="{implode(' ',$liclass)}">
      <a{if count($aclass) > 0} class="{implode(' ',$aclass)}"{/if} href="{$node->url}"{if $node->target ne ""} target="{$node->target}"{/if}><span>{$node->menutext}</span></a>
      {if isset($node->children)}
        {include file=$smarty.template nodes=$node->children}
      {/if}
    </li>
  {/if}
{/foreach}
{$depth=$depth-1}
</ul>

{if $depth == 0}

</nav><!--main-nav-end-->
{/if}
{/strip}
Thank you

Re: Menu based on cssmenu

Posted: Fri Apr 17, 2020 11:20 am
by TPrigas
Here's my system information:

----------------------------------------------

Cms Version: 2.2.14

Installed Modules:

AdminSearch: 1.0.5
CGExtensions: 1.65.2
CMSContentManager: 1.1.9
CmsJobManager: 0.1.3
DesignManager: 1.1.8
Disqus: 2.1.3
FileManager: 1.6.11
FilePicker: 1.0.4.1
Gallery: 2.4.2
MicroTiny: 2.2.4
ModuleManager: 2.1.7
Navigator: 1.0.9
News: 2.51.9
PDFGenerator: 1.0
Search: 1.51.8

Config Information:

php_memory_limit:
max_upload_size: 16000000
url_rewriting: none
page_extension:
query_var: page
auto_alias_content: true
locale:
set_names: true
timezone: Africa/Luanda
permissive_smarty: false

Php Information:

phpversion: 7.3.16
md5_function: On (Verdadeiro)
json_function: On (Verdadeiro)
gd_version: 2
tempnam_function: On (Verdadeiro)
magic_quotes_runtime: Off (Falso)
E_ALL: 32759
E_STRICT: 2048
E_DEPRECATED: 8192
test_file_timedifference: No time difference found
test_db_timedifference: No time difference found
create_dir_and_file: 1
memory_limit: 128M
max_execution_time: 180
register_globals: Off (Falso)
output_buffering: On
disable_functions: exec, passthru, shell_exec, system
open_basedir:
test_remote_url: Sucesso
file_uploads: On (Verdadeiro)
post_max_size: 16M
upload_max_filesize: 16M
session_save_path: /var/cpanel/php/sessions/ea-php73 (1733)
session_use_cookies: On (Verdadeiro)
xml_function: On (Verdadeiro)
xmlreader_class: On (Verdadeiro)
check_ini_set: On (Verdadeiro)
curl: On

Performance Information:

allow_browser_cache: On (Verdadeiro)
browser_cache_expiry: 60
php_opcache: Off (Falso)
smarty_cache: Off (Falso)
smarty_compilecheck: On (Verdadeiro)
auto_clear_cache_age: On (Verdadeiro)
Server Information:

Server Software: Apache
Server Api: fpm-fcgi
Server Os: Linux 3.10.0-1062.4.3.el7.x86_64 On x86_64
Server Db Type: MySQL (mysqli)
Server Db Version: 10.3.22
Server Db Grants: Encontrada uma declaração "GRANT ALL" que parece ser adequada

Permission Information:

tmp: /home/ormedao/public_html/tmp (0755)
tmp_cache: /home/ormedao/public_html/tmp/cache (0755)
templates_c: /home/ormedao/public_html/tmp/templates_c (0755)
modules: /home/ormedao/public_html/modules (0755)
uploads: /home/ormedao/public_html/uploads (0755)
Mascara de Criação de Ficheiros (umask): /home/ormedao/public_html/tmp/cache (0755)
config_file: 0444
----------------------------------------------

Re: Menu based on cssmenu

Posted: Fri Apr 17, 2020 6:20 pm
by DIGI3
Check that your html validates, and that there's nothing in the error console (F12).

Failing that, supply us with a link where we can see the page (not) working.

Re: Menu based on cssmenu

Posted: Sat Apr 18, 2020 9:34 am
by TPrigas

Re: Menu based on cssmenu

Posted: Sat Apr 18, 2020 12:04 pm
by velden
I suspect your javascript to interfere with the links.

https://ordemdosmedicos.co.ao/uploads/ormed/js/main.js

Re: Menu based on cssmenu

Posted: Sat Apr 18, 2020 2:16 pm
by DIGI3
Velden is correct - putting preventDefault() on links does exactly that - prevents the default action. You'll need to make it more specific to section headers or something.

Re: Menu based on cssmenu

Posted: Sat Apr 18, 2020 4:12 pm
by TPrigas
Gotit Guys...

I need the preventDefault function for a few pages. Simply created another js without that funcion

Problem solved!

Thanks a lot!