XF 2.1 fix thread in widget

DCMS

Active member
hello
is there a way to fix a thread (maybe with a little preview or image) in a widget to the side of forum?
similar to advertising widget but without ads.
just title, may the first image, and a few rows of text... so when someone click there go directly to that specific thread.

thanks

Annotazione 2020-04-23 105152.webp
 
Oh you mean make it sticky. Gotcha.

You should be able to create an HTML widget to do that and even add in something in "Display Condition" to have it expire automatically.

The basic HTML part would look like this (if you're using full friendly URLs) - using this thread as an example:

HTML:
<p>
<a href="https://xenforo.com/community/threads/fix-thread-in-widget.179529"><img source="https://xenforo.com/community/attachments/annotazione-2020-04-23-105152-jpg.223173/"><br />XF 2.1 - fix thread in widget | XenForo community</a>   
</p>
 
Last edited:
  1. AdminCP >> Appearance >> Widgets
  2. Click Add widget, top right corner.
  3. On the next page, select HTML as the Widget definition (from the dropdown). Then click Add widget.
  4. Widget key: sticky_thread_widget
  5. Title: Sticky thread widget
  6. Choose where you want the sidget to appear (Display in positions) and the ordinal position compared with other widgets shown there.
  7. Display condition: leave blank for now.
  8. Template: Your HTML goes here
  9. Advanced mode: unchecked means border around the widget, checked means no border.
 
Oh you mean make it sticky. Gotcha.

You should be able to create an HTML widget to do that and even add in something in "Display Condition" to have it expire automatically.

The basic HTML part would look like this (if you're using full friendly URLs) - using this thread as an example:

HTML:
<p>
<a href="https://xenforo.com/community/threads/fix-thread-in-widget.179529"><img source="https://xenforo.com/community/attachments/annotazione-2020-04-23-105152-jpg.223173/"><br />XF 2.1 - fix thread in widget | XenForo community</a>  
</p>

I like the idea of this a lot! To better understand it, how would I call for example this thread in your code?

Thanks!
 
Note: in the HTML I posted (in a hurry) above, img source= is incorrect. It should read img src=.

@Jim Fox, for your link it should be something like this:
HTML:
<p>
<a href="https://www.focalworld.com/index.php?threads/final-bloom.12733/"><img src="https://www.focalworld.com/data/avatars/l/0/328.jpg?1515040475"><br />final bloom | FocalWorld</a>  
</p>
I've used the avatar of the OP for the image.

Could also use the image in the first post instead - I haven't tried this with attachments but I think it should work:
HTML:
<p>
<a href="https://www.focalworld.com/index.php?threads/final-bloom.12733/"><img src="https://www.focalworld.com/index.php?attachments/2020_april_flower_39_web-jpg.27478/"><br />final bloom | FocalWorld</a>  
</p>
but you'd probably need to add height and width limits...
HTML:
<p>
<a href="https://www.focalworld.com/index.php?threads/final-bloom.12733/"><img src="https://www.focalworld.com/index.php?attachments/2020_april_flower_39_web-jpg.27478/" width="300" height="300"><br />final bloom | FocalWorld</a>  
</p>
You could use some CSS in extra.css to make this responsive according to screen size or available space. For examples, see
 
Could also use the image in the first post instead - I haven't tried this with attachments but I think it should work:
HTML:
<p>
<a href="https://www.focalworld.com/index.php?threads/final-bloom.12733/"><img src="https://www.focalworld.com/index.php?attachments/2020_april_flower_39_web-jpg.27478/"><br />final bloom | FocalWorld</a>
</p>
but you'd probably need to add height and width limits...

it work very very properly! thread link and preview image! no need to adjust size width limits!
 
@djbaxter I finally got to try it, and it does work awesome! Thanks so much, it's really so cool looking and will be a great addition.

Two questions.

1. For the Attachment part how did you get that info? I found if I replied to the post that in my Reply it would have a "View Attachment" link at the bottom of the post, that supplied the attachment info for me, but is there an easier way for me to get the Attachment info?

2. If someone has inserted a photo from the Media Gallery into the post, is there a way to grab that photo and put it in this widget? Or will it just be limited to photos that people have uploaded as an attachment?

Thanks so much!
 
What I did was right click on the image.

In Firefox, I then have a context menu item for "Copy location of image" (an extension I think).

Othewise, choose "open in new tab" if you can and then use the full URL in that tab.
 
Top Bottom