XF 1.4 Place a widget within a notice?

DaveL

Well-known member
Im looking to create a notice within a certain section of my site. Within the notice I wish to place a widget such as the one on this page - http://www.worldtimebuddy.com/clock-widget

Is it possible to get this to work within a notice? I have tried and it only displays the code, not the widget.

Code:
<span class="wtb-ew-v1" style="width: 204px; display:inline-block"><script src="http://www.worldtimebuddy.com/clock_widget.js?h=0&bc=00A2E8&cn=&wt=c1"></script><i><a href="http://www.worldtimebuddy.com/gmt-to-pst-converter">gmt time to pst</a></i><noscript><a href="http://www.worldtimebuddy.com/gmt-to-pst-converter">gmt time to pst</a></noscript><script>window[wtb_event_widgets.pop()].init()</script></span>

If its not possible, im presuming this conditional would do the trick?

26. How can I show content in a specific forum?
<xen:if is="{$forum.node_id} == x">
This content will show in forum x
</xen:if>

Would that display where the notice would normally be placed? If so, Does anyone know what code I would use to get the content displayed in a notice like box?

Also, which template would I need to make that edit in?
 
I tried your code in a notice and it seems to work OK for me:
clock.webp

If its not possible, im presuming this conditional would do the trick?
That conditional will only work in templates, you can't use that in Notices.

But if you want that notice to only show for a particular node you can easily set that in Edit Notice -> Page Criteria -> Page is Within Nodes:
 
I tried your code in a notice and it seems to work OK for me:
View attachment 96816


That conditional will only work in templates, you can't use that in Notices.

But if you want that notice to only show for a particular node you can easily set that in Edit Notice -> Page Criteria -> Page is Within Nodes:

How strange! Ive tried everything and I just cant get the code to work in a notice!

Regarding the conditional, I was asking which template I include that in to get the script to show at the top of a certain forum - not actually within a notice, but where a notice is normally displayed.
 
Ok, im getting closer!

However for some reason when I save the notice after inputting the code, its stripping most of it out and only displaying the URL.

Any advice on why it might be doing this?
 
That is truly peculiar, as Notices definitely do allow HTML.

Certainly it is not stripping on mine:
test-notice.webp

Sorry I'm not sure why it would be stripping the HTML, hopefully someone can chime in with some ideas. :unsure:
 
That is truly peculiar, as Notices definitely do allow HTML.

Certainly it is not stripping on mine:
View attachment 96820

Sorry I'm not sure why it would be stripping the HTML, hopefully someone can chime in with some ideas. :unsure:

Very strange. This is what I get when I save it

time.webp

Thanks anyway, appreciate your help.

Hopefully someone might be able to help shed some light on it!
 
I am with DaveL on this.

I have been trying to use a voice-comms monitor thing from the interweb, and according to one of my coders, xenforo is "stripping the <script>" out of the code, causing it to stop working and constantly in the "loading" phase. I did some reasearch and found another 3 cases of this nature with certain script and/or comms-viewer code.

oAn7lNc.png


I need a solution to this; this is just a silly error, surely. And it's incredibly frustrating.

Code:
<div id="vcv-b"><div id="vcv-l"><div class="hd"><img alt="Multiplay" src="http://commsviewer.com/imgs/multiplay.png" />&nbsp;<a href="http://commsviewer.com" target="_blank">Multiplay Voice Comms Viewer</a></div><div id="vcv-i">Loading... <img src="http://commsviewer.com/imgs/progress.gif" alt="Progress" /></div><div class="ft"><b>Need Voice Comms?</b>&nbsp;<a href="http://www.multiplaygameservers.com/voice-comms/" target="_blank">Multiplay's Voice Comms Servers!</a></div></div></div><script type="text/javascript"> var _vcv={cfg:'cvserverid=12476'}; (function() {var mp=document.createElement('style'); mp.type='text/css'; var s='#vcv-l{ border:1px solid #99BBE8; font-family:serif; font-family:tahoma,arial,verdana,sans-serif; -moz-box-shadow:2px 2px 5px rgba(0, 0, 0, 0.5); -webkit-box-shadow:2px 2px 5px rgba(0, 0, 0, 0.5); box-shadow:2px 2px 5px rgba(0, 0, 0, 0.5); width:300px; text-align:center; font-size:13px; color:#000;} #vcv-i{ background-color:#fff; padding:5px;} #vcv-l a, #vcv-l a:hover, #vcv-l a:visited { text-decoration:none; color:#15428B; font-weight:bold;} #vcv-l a:hover { text-decoration:underline; color:#15428B;} #vcv-l .hd,#vcv-l .ft{ background-color:#D2DFF0; padding:3px 5px;} #vcv-l .hd{ border-bottom:1px solid #99BBE8; text-align:left;} #vcv-l .ft{ border-top:1px solid #99BBE8; font-size:10px;} #vcv-l img{ border:0; vertical-align:sub;}'; if ( mp.styleSheet ) {mp.styleSheet.cssText=s;} else {mp.innerHTML=s;} var s=document.getElementsByTagName('head')[0]; s.appendChild(mp); mp=document.createElement('script'); mp.type='text/javascript'; mp.async=true; mp.src=('https:' == document.location.protocol ? 'https://' :'http://') + 'commsviewer.com/js/loader-min.js'; s=document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(mp, s);})(); </script><noscript id="vcv-ns">You need Javascript enabled to use <a href="http://commsviewer.com" target="_blank">Voice Comms Viewer</a></noscript>
 
@Ross Hardy: I did notice this error in the console when trying your code in XenForo:
error.webp
Unfortunately I'm not a coder so I don't know where to troubleshoot for that. But as it's an external script it's likely it is clashing with one of XenForo's Javascript libraries (possibly jQuery?)
 
@Ross Hardy: I did notice this error in the console when trying your code in XenForo:
View attachment 103194
Unfortunately I'm not a coder so I don't know where to troubleshoot for that. But as it's an external script it's likely it is clashing with one of XenForo's Javascript libraries (possibly jQuery?)

Thanks for taking the time out to try it!

Yes, my coding team actually said it was an issue on the xF side of things, but unfortunately as good as my coding team are, they don't know xF code to try and resolve it. I was hoping someone on these boards would have a solution; it really is a silly, minor incompatibility which shouldn't be there. I might sound "mad", I am a little, because it's such a small thing which should work.
 
Back
Top Bottom