Link entries

  • Hey guys,


    SAB   yns.wtf   SPQRInc i hope you doing well. However I would like to make an improvement for Link Entries in the menu. I have an pagekit instance at my workplace running as Intranet System with deep intergration of companies quality mangement system, which originaly document based in a little bit outdated form. Well it's working fine so far except one little thing with those links i would like to change it slighly.


    I create Links to PDF Documents after i upload them to the storarge, well the normal function is to open this document in same window, i would like to open it in a new tab. it's the menu.php in views\system\site folder inside my template that is based on theme one originally, but i use the uikit 3 ported version. Well now the question: Is it possible to add target="_blank" but only to links? As i have many links as well to sub pages and those should open still in same window not in new tabs.


    Im sure if i change the following line to the following that it will affect both types, pages and links.


    Code
    1. <a href="<?= $node->getUrl() ?>" target="_blank"><?= $node->title ?></a>

    So probably you have an idea how to filter that it applies to link entries only?


    Thanks for any advice in advance


    Regards,


    Fossy

  • You can check the node type with $node->type == 'link' as the type property of the Node object is public. You can also check for any other type like this. Node types are determined via the index.php of all modules. Pagekit has two types: 'page' and 'link', if blog is installed also 'blog'.


    Custom types can be added by extensions: https://pagekit.com/docs/devel…ister-nodes-for-site-tree


    Types get registered during runtime:

    The LORD is my strength and my shield; in him my heart trusts, and I am helped; my heart exults, and with my song I give thanks to him. Psalm 28,7

  • You can check the node type with $node->type == 'link' as the type property of the Node object is public. You can also check for any other type like this. Node types are determined via the index.php of all modules. Pagekit has two types: 'page' and 'link', if blog is installed also 'blog'.


    Custom types can be added by extensions: https://pagekit.com/docs/devel…ister-nodes-for-site-tree


    Types get registered during runtime:

    Thank you very much so something like:


    could do the job?


    Regards,


    Fossy


    p.s. edit:


    well I tried even just to add target="_blank" parameter to every entry as i wrote in my initial post, but the system is ignoring it completely, if i do a mistake in syntax i get an error, but if not it's just same behaviour as i did not changed a thing...


    p.p.s edit 2:


    my bad i had to create a file widget-menu.php to override as I'm using the side menu for linking documents.


    Well however if i use if expression or not when i add the blank target argument it's always opening in a new tab. Even the type isn't link or does any entry get a link type anyway?

    • Helpful
    PHP
    1. <a href="<?= $node->getUrl() ?>" <?= $node->type == 'link' ? 'target="_blank"' : ''?> >
    2.     <?= $node->title ?> <?= $node->type ?> <?-- <- for debugging ?>
    3. </a>

    Your last statement is not clear to me - it always adds the target attribute?

    The LORD is my strength and my shield; in him my heart trusts, and I am helped; my heart exults, and with my song I give thanks to him. Psalm 28,7

  • Hi SAB ,


    seems to be my theory was right. I did enabled the code you gave and now i see every link twice as the link entry itself and same link with type behind and every link has the link behind it. I guess that confirms my theory that each link neither it's a page or not get the link type anyway on top right?



    regards


    Fossy

  • Damn stupid me sorry sab for bothering you. I must have had big tomatoes on my eyes. :)

    PHP
    1. <?php if ($node->type == 'link') : ?>
    2.     <a href="<?= $node->getUrl() ?>" target="_blank"><?= $node->title ?></a>
    3.     <?php elseif ($node->type != 'link') : ?>
    4.         <a href="<?= $node->getUrl() ?>"><?= $node->title ?></a>
    5. <?php endif ?>

    This one works fine so far, i guess i had it yesterday already, but forgot that i have created a main topic as link to the page entry where the handbook starts...


    So my bad at all, but thank you very much for your help i apppreciate that very much and learned again a bit thanks mate!


    Regards,


    Fossy

  • I have to smile... Prozesslandkarte.... It has been ages since I have been working in this space and hence seen the term.