Open the links in the same window

Greetings @Bryan_Wunsch and welcome to Elfsight ranks :tada:

We are so grateful for your feedback and interest in this feature, this is huge!

Rest assured, we’ll keep you in the loop regarding any changes :slightly_smiling_face:

Hey Helga & Max, sorry to bother on this again, but another 5 month past and I will continue asking for this feature as it is very crucial for many of my customers (and for all my own websites). Right now, everyone is accepting that Portfolio is opening on a new window, however, customers are waiting for your dev team to make it possible of opening Portfolio in the same window. Hope they will get some time soon to work on this.

1 Like

Hi Markus, my apologies for the long reply!

I cannot express how sorry I am that this request is taking so much time to be released. You know, I’ve had a chat with the devs, and the only reason for the delay is our need to prioritize things. Since we’re still a relatively small team, we have to focus on more popular requests first, so the votes for requests really matter here.

I’ve asked our devs to bump up this request if possible, but I cannot guarantee that it will speed up the development process. I’m afraid the only thing I can advise here is that your clients vote for this feature too, so that we can add it to our roadmap when it has more votes.

Once again, I’m really sorry for this situation, Markus.

1 Like

Is there no way to add something into the custom JS of the app on Elfsite to force the link to load in the same window? Would be a quicker fix than waiting on the devs

I’m no coder but looking at the portfolio.js I think we need to over-right the following within “function un(t)” line 13786

r && window.open(r),

with

r && window.open(r, _self),

Any ideas on if/how we can do this via the custom JS on the plugin page?

@Helga - any chance you could ask the Dev’s to give us this and we can add it in ourselves to tide us over until it’s added in

2 Likes

It would be great if Helga / the devs would have such a code. I have no clue about JS so I would need to get a full code. I am using the Portfolio widget already on 28 pages, it would help a lot to solve this hassle :blush:

Thanks user10226 for your idea, let’s see what Helga thinks about it. :blush:

1 Like

@Markus - may have cracked it. Add the following to the custom JS panel

(function(window, open) {
window.open = function(url) {
open.call(window, url, ‘_self’);
};
})(window, window.open);

1 Like

@user10226 @Markus thank you so much for your thoughts here, guys!

We’re now discussing this possibility with our devs, we’ll get back to you once we know what they think about it :blush:

@Helga Thank you, I really appreciate this :blush:

@user10226 Thanks for trying. Unfortunately, it’s not working. A lot of error messages show up, but thanks anyway.

Line 131: Unexpected ‘‘’.

Line 132: Expected an identifier and instead saw ‘}’.

Line 132: Expected ‘)’ and instead saw ‘;’.

Line 132: Missing semicolon.

Line 133: Missing semicolon.

Line 133: Expected an identifier and instead saw ‘)’.

Line 133: Expected an operator and instead saw ‘(’.

Line 133: Expected an assignment or function call and instead saw an expression.

Line 133: Missing semicolon.

Line 133: Expected an assignment or function call and instead saw an expression.

Line 133: Missing semicolon.

Line 133: Expected an identifier and instead saw ‘)’.

Line 133: Expected an assignment or function call and instead saw an expression.

Line 129: Unmatched ‘{’.

Line 133: Unrecoverable syntax error. (100% scanned).

works for me - check out Product Development / Innovation Portfolio to see it working on the website. Maybe try and type it in as opposed to copy and pasting

@Markus @user10226, here’s the solution our devs have suggested, but please note that the widgets have to be installed on different pages throughout the website. Otherwise, there might be a conflict:

const link = "https://apps.elfsight.com/p/boot/?page=" + window.location.href;
let globalSettings;

const checkClick = (settings) => {
  const items = [
    ...document.querySelectorAll(
      ".eapp-portfolio-project-look-card-with-click-action"
    ),
  ];
  items.forEach((item) => {
    item.addEventListener("click", (e) => {
      e.preventDefault();
      e.stopPropagation();
      const findClickCard = settings.find(
        (card) => card.name === item.childNodes[1].childNodes[0].textContent
      );
      if (Object.keys(findClickCard).length !== 0) {
        window.open(findClickCard.website, "_self");
      }
    });
  });
};

const init = async (portfolio) => {
  const settings = await fetch(`${link}&w=${portfolio}`)
    .then((response) => response.json())
    .then(({ data }) => data.widgets[portfolio].data.settings.projects);
  globalSettings = settings;
  checkClick(settings);
};

const interval = setInterval(() => {
  const elfsight = document.querySelector(
    ".eapp-portfolio-portfolio-projects"
  );

  if (!!elfsight) {
    clearInterval(interval);

    const portfolio = elfsight.parentNode.parentNode.parentNode.id.replace(
      "eapps-portfolio-",
      ""
    );

    const tabs = document.querySelector(
      ".eapp-portfolio-project-list-categories-component"
    );
    const loadMore = document.querySelector(
      ".eapp-portfolio-project-list-load-more-component"
    );
    !!tabs &&
      tabs.addEventListener("click", () => {
        setTimeout(() => checkClick(globalSettings), 500);
      });

    !!loadMore &&
      loadMore.addEventListener("click", () => {
        setTimeout(() => checkClick(globalSettings), 500);
      });
    init(portfolio);
  }
}, 100);

Could you please try this script out and let me know how it worked?

1 Like

And here’s the second solution the devs have just come up with. It might work even better:

document.addEventListener(
	'click',
	(e) => {
		const card = e.target.closest(
			'[class*="eapp-portfolio-project"][class$="item"]'
		);

		if (!card) {
			return;
		}
		const copyWindowOpen = window.open;
		window.open = (url) => copyWindowOpen(url, '_self');

		setTimeout(() => (window.open = copyWindowOpen));
	},
	true
);

Let us know which script worked best for you :slight_smile:

1 Like

working for me! thanks @Helga

2 Likes

Thank you Helga & devs! This code is working well. I have some pages where I have two portfolios on the same page installed.

With this code it’s working so far. Will implement this code now step by step to all the widgets and test every page first.

Thank you, it’s a super thing for all my customers if this will work!

2 Likes

Oh no, thank YOU, @user10226, for making this workaround happen :slight_smile:

@Markus, I hope you will be fine with this solution and it will work as expected :slight_smile:

By the way, which code you guys decided to use?

1 Like

Thanks Helga, I will continue with the work tomorrow and let you know then.

Have a good evening :blush:

2 Likes

Friends, this feature is in development now! It’s on the Code Review stage now, so chances are it will be available quite soon :slight_smile:

2 Likes

Super, hope it will be available soon :upside_down_face:

1 Like

Hey guys :wave:

The feature is finally released!!! You can find the new setting in the Action on Project Click section on the Project tab

image.


Test it out and share your experience with us :wink:

2 Likes

Hey Max,

This is awesome! I changed all my customers, and it works perfectly!

Thanks to the devs that it finally happens. This is an important functionality.

Brgds, Markus

2 Likes