Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
general-topic
Show link in popup
Avatar
Erik Wanrooij
Member
Free Members
sp_UserOfflineSmall Offline
Jun 15, 2015 - 8:20 am

Hi,

How can I create a link that opens a textfile as a popup (eg like the policy-plugin shows the privacy policy textfile)?

I'd like to create such a link in an announcement (using the announcement-plugin).

Regards,

Erik

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Jun 15, 2015 - 11:38 am

I guess I really have to start by asking how good your php and javascript is as well as asking if it is always the same text file you want to open or can it be different files depending upon some condition?

andy-signature.png
YELLOW
SWORDFISH
Avatar
Erik Wanrooij
Member
Free Members
sp_UserOfflineSmall Offline
Jun 15, 2015 - 1:03 pm

PHP: moderate, javascript: not so good..

And yes, it's always the same file. 

 

Thanks,

Erik

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Jun 15, 2015 - 1:33 pm

Actually you should be able to do this using just php.

Any code you write should be either placed in the 'spFunctions.php' file of your SP theme (and use a child theme to save losing changes on updates) - or - since Simple:Press version 5.5.7 you can drop a php file named 'sp-user-functions.php' into the wp-content folder and it will be included. This is then safe from future updates.

The Announcements plugin has a standard WP style filter hook you can use to add content to the announcement display. This is named  'sph_AnnounceMessage' and sends the $content to be changed/added to etc. There are details of this on our codex page for this plugin.

A dialog box can  be opened by sending the content directly to it in something like an onclick event. So the button you add can use onclick. The JS function and calling arguments are:

spjDialogHtml(e, content, title, width, height, position, dClass)

made up of:

e the button/link object making the call
content the formatted content to be displayed
title text for the popup title bar
width width of the popup or 0 for auto
height height of popup or 0 for auto
position set to zero to calculate. Or 'center'
dClass optional class to apply to overall dialog container

If you are able to search through our code you will find a few examples. We could advise on this of course.

andy-signature.png
YELLOW
SWORDFISH
Avatar
Erik Wanrooij
Member
Free Members
sp_UserOfflineSmall Offline
Jun 15, 2015 - 3:33 pm

Thank you! I'm affraid I need more help.. This is what I read in the codex:

apply_filters(‘sph_AnnounceMessage’, $out, $a)

So I guess that call goes into spFunctions.php, right?

Now, should $out contain the extra content I like to add to the announcement:

spjDialogHtml($this, url_to_texfile, "title", 500, 400, "center")   ?

I hope I'm moving into the right direction.. I tried to learn more about plugin-hooks, however unfortunately the section "plugin hooks" in the codex says "needs writing".

Thanks ,

 

Erik

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Jun 15, 2015 - 3:52 pm

For a tutorial on hooks see: http://codex.wordpress.org/Plugin_API

Essentially you would add your content additions to the $out variable and then pass it back in a return statement. So something like:

add_filter('sph_AnnounceMessage', 'your_announcement_content');
function your_announcement_content($content) {
 $content .= '---what you want to add---';
 return $content;
}

So there you would add your button with the onclick call to spjDialogHtml() and the data you send that would need to include the text of the text file.

andy-signature.png
YELLOW
SWORDFISH
Avatar
Erik Wanrooij
Member
Free Members
sp_UserOfflineSmall Offline
Jun 18, 2015 - 6:08 am

Thank you Andy, I'm getting there... Also, I should have read that manual on hooks earlier.. Instead of spjDialogHtml I use spjDialogAjax now, not sure why but only the latter allowed me to refer to the URL of a textfile and load its contents. 

So thanks for your help! - it's much appreciated 🙂

Erik

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Jun 18, 2015 - 6:29 am

Ah - the more complex option! Very glad to hear you are in your way. It is so nice to see people use some of these functions...

andy-signature.png
YELLOW
SWORDFISH
Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 650
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 619
Members: 17361
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10127
Posts: 79625