Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QUESTION open page in new window
#1
Is it possible to open specific paged in "new window" - via standard settings or via plugin?

Greetings
df8oe
Reply
#2
If you mean a link inserted in the page editor (ckeditor), you can edit the link properties and select as Target:
New Window (_blank)
Reply
#3
Thanks - but I am meaning pages which are accessed via getsimple menu.
Reply
#4
(2018-11-04, 19:59:11)df8oe Wrote: Is it possible to open specific paged in "new window" - via standard settings or via plugin?

Greetings
df8oe

No problem with i18n navigation.

Frist create a component called "mynavigation". In this component you can check whether this site has to open in a new window or not. In this example, all menuitems which link to a pdf file are opened in target=_blank:
PHP Code:
<li class="<?php echo $item->classes; ?>">
 
 <a href="<?php echo htmlspecialchars($item->link); ?>" <?php if(strpos($item->link,'pdf')) echo 'target="_blank"'?> >
    <?php echo htmlspecialchars($item->text); ?>
  </a>
  <?php if ($item->isOpen) { ?>
    <ul class="sub-menu"><?php $item->outputChildren(); ?></ul>
  <?php ?>
</li> 

Call your navigation in the template with

PHP Code:
<?php get_i18n_navigation(return_page_slug(),0,99,I18N_SHOW_NORMAL,'mynavigation'); ?>

That's all.

Alex
Reply
#5
Hi Alex,

nice work and method. It works 100% but you have to add the menu entries manually to the template and if you change template you have to redo the changings.

I am looking for something like that:
(1)
If you create a new page you get an option under "show this page in menu" where you can select the target (e.g. after "placement of menu entry"). Normally it is predefined as "same window" - but you can selevt other targets, too

(2)
If you put a complete URL to "slug" the created menu entry will be an external link - can be to a page or to a file. All text you put to the page is without any influence. But the position of the link in menu and the target are working in this "mode", too.

It would be very easy implementation to getsimple base files. Both would need only a few lines to be added. I wonder if this feature is interesting for the project. It is overshooting to create a plugin for this. Additionally I haven't read the API documentation if this can ve done via plugin. If it is interesting for the project I would fork GitHub, do the additions and make a pull request. But I want to be future-proof so I do not want to make it only for my use. Every update would trash the additions.

df8oe
Reply
#6
Hi df8oe,

As to your point (1)
The call
PHP Code:
<?php get_i18n_navigation(return_page_slug(),0,99,I18N_SHOW_NORMAL,'mynavigation'); ?>
does use the normal menu system (but with the _i18n_ variant). An unnumbered <ul><li>... list is generated, of which you are able to implement the rendering of the <li> entries yourself in the component 'mynavigation', which Alex adapted for your needs from mvlcek's i18n web page.
This component remains accessible from all templates within the same theme. The shared component 'mynavigation' takes care of the logic.
If you need a menu, you would have to include the same call to get_i18n_navigation, so I don't understand your objection, unless you want to manually construct your very own <ul><li>... list.

As far as the filtering goes (for the sake of example, Alex's code filters for .pdf filenames), but you could use different selection criteria to recognize the pages for which you wish to add ' "target=_blank" ' to the menu link. 
E.g., you could also use a tag (keyword), e.g., 'blank'. 
(Don't use '_blank', as some of mvlcek's i18n code gives special treatment to tags starting with '_' (using it as a prefix for a subcommand), and sometimes ignores such tags if you want to put them to use for your own purposes).
Code:
if (pageHasMetaTag('blank')) { echo ' target="_blank"'; }
where 
Code:
function pageHasMetaTag($keyword) {
  $metaKeywordArr = array_map(trim,explode(',',get_page_meta_keywords(false)));
  return in_array($keyword,$metaKeywordArr);
}
I have this function tucked somewhere in a component and it already has served me well.
Reply




Users browsing this thread: 1 Guest(s)