XF 2.2 Possible to switch widgets in the same position via a link?

EchoRomeo

Active member
Hi everyone,

If I have a widget somewhere on a page, is it possible to have a link available that, when clicked, changes out the widget for another one? I'm playing around with search forum widgets and want to be able to display the results of different search forums dynamically, in the same widget position, when different links are clicked. I thought about using iframe, but for that to work I'd need a src value for each widget...something like that doesn't exist does it?

Thanks!
 
Solution
I had the same thought about using iframe. Like you said, I'd need to find a way to capture each search forum widget on it's own clean page and without any other forum container...not sure how straightforward that might be.

  • To remove the default forum container, create a style with page_container edited to remove header (see below), title etc so it just shows blank page.
  • Create your page node and choose that style to overrideScreenshot 2024-02-11 at 10.17.44.webp
  • Add your search forum widget to the page. <xf:widget key="your_widget" />
  • Now make this page the iframe that your image map link opens
  • Repeat for each state
This is what I use for page_container in blank style

See here...
Hi everyone,

If I have a widget somewhere on a page, is it possible to have a link available that, when clicked, changes out the widget for another one? I'm playing around with search forum widgets and want to be able to display the results of different search forums dynamically, in the same widget position, when different links are clicked. I thought about using iframe, but for that to work I'd need a src value for each widget...something like that doesn't exist does it?

Thanks!
Maybe something like this?
 
Thanks for sharing that - that's good to know and very neat but isn't quite what I have in mind :). It's nice you can put multiple widgets in the same container like that but the trick would be triggering the widget displayed to change without using the scroller.

See attached for a better depiction of what I'm talking about. Is this the kind of thing that requires custom development?
 

Attachments

  • Screenshot 2024-02-10 094301.webp
    Screenshot 2024-02-10 094301.webp
    62.1 KB · Views: 17
Last edited:
It would be quite a neat thing, and I can see the use. It may be possible by making the map an html image map, ie you use coordinates to define a clickable link area. If each link was to an iframe, each of which was a page with a specific search forum widget then it might just work.

Or else the link opened a an overlay popup page with a widget might actually be easier and more elegant.

But someone will be along soon within better easier way.
 
It would be quite a neat thing, and I can see the use. It may be possible by making the map an html image map, ie you use coordinates to define a clickable link area. If each link was to an iframe, each of which was a page with a specific search forum widget then it might just work.

Or else the link opened a an overlay popup page with a widget might actually be easier and more elegant.

But someone will be along soon within better easier way.

Thanks @Mr Lucky, yeah since permitting issues are most relevant to people at the local level I'm trying to use custom user fields to get people's areas of interest at registration (e.g., Alabama) and then make maps/search forum widgets for those areas visible to them on my homepage based on those profile settings. Hopefully I'm able to do something like what I'm exploring above.

Thanks for the tip about image maps! I'm actually using a set of HTML5 maps for all U.S. states/counties (e.g., the one I attached above) that I purchased from www.simplemaps.com. I can specify the URL for each polygon for the customized maps I make on the site. They also host the HTML/script and I just have to embed it. But yeah, there was potentially a free/easy solution involving image maps out there...

I had the same thought about using iframe. Like you said, I'd need to find a way to capture each search forum widget on it's own clean page and without any other forum container...not sure how straightforward that might be.
 
I had the same thought about using iframe. Like you said, I'd need to find a way to capture each search forum widget on it's own clean page and without any other forum container...not sure how straightforward that might be.

  • To remove the default forum container, create a style with page_container edited to remove header (see below), title etc so it just shows blank page.
  • Create your page node and choose that style to overrideScreenshot 2024-02-11 at 10.17.44.webp
  • Add your search forum widget to the page. <xf:widget key="your_widget" />
  • Now make this page the iframe that your image map link opens
  • Repeat for each state
This is what I use for page_container in blank style

See here:

 
Last edited:
Solution
I do think it is worth trying an overlay (popup) instead of iframes. Just add data-xf-click="overlay" to the link/s to the page with widget.

EDIT: don't even need the page with a widget - just link to the search forum itself
 
Last edited:
  • To remove the default forum container, create a style with page_container edited to remove header (see below), title etc so it just shows blank page.
  • Create your page node and choose that style to overrideView attachment 298004
  • Add your search forum widget to the page. <xf:widget key="your_widget" />
  • Now make this page the iframe that your image map link opens
  • Repeat for each state
This is what I use for page_container in blank style

See here:


Thank you so much! Interesting idea using the blank style with pared down page_container. I'm going to tinker with this more tonight (when I have a bit more time) and confirm that this works with my map/search forum widget block.
 
Thanks again to @Mr Lucky for the assist on this one!

If anyone's interested, you can check out my homepage to see my brand new clickable map/search forum iframe.

A couple notes...

EDIT: don't even need the page with a widget - just link to the search forum itself

I think you do need the page actually, since in my case I wanted to display the threads in widget form. When you link directly to the search forums you see the forum pages as they display on a forum page, which I don't think works...however, I didn't try linking to search forum pages with 'override style choice' set to 'blank' so perhaps that would have worked okay.

Also, when I initially set up the map links to target the iframe I ran into the issue of the search forum widget links - those that appear in the iframe - opening within the iframe and not in the parent window. I solved the issue by adding the following HTML to each blank page alongside the widget code:

Code:
<base target="_top" />
 
When you link directly to the search forums you see the forum pages as they display on a forum page, which I don't think works...however, I didn't try linking to search forum pages with 'override style choice' set to 'blank' so perhaps that would have worked okay.
No I meant only link to the forum if the link to search forum in an overlay using data-xf-click="overlay", that way it won't show as a forum page. As you have looks great but not at all browser widths:
Screenshot 2024-02-13 at 11.25.24.webp
 
No I meant only link to the forum if the link to search forum in an overlay using data-xf-click="overlay", that way it won't show as a forum page. As you have looks great but not at all browser widths:

Got it. I'll check that out when I have the chance. I appreciate that suggestion...I do see what you're saying about the text getting all scrunched up when the window's narrow.

Aside from this, I always appreciate any candid advice/perspective @Mr Lucky can provide :). If you have any feedback in general, don't hesitate to send it my way!
 
Back
Top Bottom