PDA

View Full Version : [Read More...] to open in a popup-window


abcohen
08-19-2005, 05:04 PM
So you want to open the read more in a popup window...

First we'll have to create a new file in the p2_news folder in the plugins directory...
lets call the file poparticle.php

inside that file you'll place this code....


<?php
// +---------------------------------------------+
// | * * Copyright © 2003 – 2005 Subdreamer, LLC |
// | * * http://www.subdreamer.com * * * * * * * |
// | * * This file may not be redistributed. * * |
// +---------------------------------------------+
error_reporting(E_ALL & ~E_NOTICE);
define('IN_SUBDREAMER', true);

$rootpath = "../../";



// ########################### LOAD SUBDREAMER CORE ############################

include($rootpath . 'includes/core.php');



// ############################ LOAD MAIN SETTINGS #############################

$getmainsettings = $DB->query("SELECT varname, value FROM " . TABLE_PREFIX . "mainsettings");
for($i = 0; $setting = $DB->fetch_array($getmainsettings); $i++)
{
*$mainsettings[$setting['varname']] = $setting['value'];
}



// ######################## ARTICLE BITFIELD SETTINGS ##########################

$p2_articlebitfield = array('useglobalsettings' * * * => 1,
* * * * * * * * * * * * * *'displayonline' * * * * * => 2,
* * * * * * * * * * * * * *'displaytitle' * * * * * *=> 4,
* * * * * * * * * * * * * *'displayauthor' * * * * * => 8,
* * * * * * * * * * * * * *'displaycreateddate' * * *=> 16,
* * * * * * * * * * * * * *'displayupdateddate' * * *=> 32,
* * * * * * * * * * * * * *'displayprintarticlelink' => 64,
* * * * * * * * * * * * * *'displayemailarticlelink' => 128,
* * * * * * * * * * * * * *'displaydescription' * * *=> 256,
* * * * * * * * * * * * * *'displaysmilies' * * * * *=> 512,
* * * * * * * * * * * * * *'displaycomments' * * * * => 1024);



// ############################## DISPLAY ARTICLE ##############################

function p2_PopArticle($article)
{
*global $DB, $p2_articlebitfield;

*// get news language
*$p2_language = GetLanguage(2);

*echo '<html>
* * * *<head>
* * * * *<title>' . $article['title'] . '</title>
* * * *</head>
* * * *<body>';

*// display title?
*if($article['settings'] & $p2_articlebitfield['displaytitle'])
*{
* *echo '<b>' . $article['title'] . '</b>';
*}

*// display author?
*if($article['settings'] & $p2_articlebitfield['displayauthor'])
*{
* *echo '<br />' . $p2_language['by'] . ' ' . $article['author'];
*}

*// display published date?
*if($article['settings'] & $p2_articlebitfield['displaycreateddate'])
*{
* *echo '<br />' . $p2_language['published'] . ' ' . iif($article['datestart'] != 0, DisplayDate($article['datestart']), DisplayDate($article['datecreated']));
*}

*// display updated date?
*if( ($article['settings'] & $p2_articlebitfield['displayupdateddate']) AND ($article['dateupdated'] != 0) )
*{
* *echo '<br />' . $p2_language['updated'] . ' ' . DisplayDate($article['dateupdated']);
*}

*// display description?
*if($article['settings'] & $p2_articlebitfield['displaydescription'])
*{
* *if(strlen($article['description']))
* *{
* * *echo '<br /><br />' . iif($article['settings'] & $p2_articlebitfield['displaysmilies'], AddSmilies($article['description']), $article['description']);
* *}
*}

*// print article
*echo '<br /><br />' . str_replace('{pagebreak}', '', $article['article']);
}



// ############################ START POP ARTICLE ############################

if( (isset($_GET['p2_articleid'])) AND (ereg("^[0-9]+$", $_GET['p2_articleid'])) AND ($article = $DB->query_first("SELECT * FROM " . TABLE_PREFIX . "p2_news WHERE articleid = '" . $_GET['p2_articleid'] . "' AND (settings & 2)")) )
{
*// get global article settings
*$getsettings = $DB->query("SELECT description, value FROM " . TABLE_PREFIX . "pluginsettings WHERE pluginid = 2");
*for($i = 0; $setting = $DB->fetch_array($getsettings); $i++)
*{
* *$settings[$setting['description']] = $setting['value'];
*}

*// create global settings
*$globalsettings = 0;
*$globalsettings += $settings['Display Title'] * * * * * * * * * * *== 1 ? 4 * *: 0;
*$globalsettings += $settings['Display Author'] * * * * * * * * * * == 1 ? 8 * *: 0;
*$globalsettings += $settings['Display Creation Date'] * * * * * * *== 1 ? 16 * : 0;
*$globalsettings += $settings['Display Updated Date'] * * * * * * * == 1 ? 32 * : 0;
*$globalsettings += $settings['Display Print Article Link'] * * * * == 1 ? 64 * : 0;
*$globalsettings += $settings['Display Email Article Link'] * * * * == 1 ? 128 *: 0;
*$globalsettings += $settings['Display Description Inside Article'] == 1 ? 256 *: 0;
*$globalsettings += $settings['Display Smilie Images'] * * * * * * *== 1 ? 512 *: 0;
*$globalsettings += $settings['Display User Comments'] * * * * * * *== 1 ? 1024 : 0;

*// use global settings for this article?
*if($article['settings'] & $p2_articlebitfield['useglobalsettings'])
*{
* *$article['settings'] = $globalsettings;
*}

*p2_PopArticle($article);
}

?>






then you'll need to link to that new display code...

in news.php.

On line 406:
* *echo ' <a href="' . RewriteLink('index.php?categoryid=' . $categoryid . '&p2_articleid=' . $article['articleid']) . '">' . $p2_language['read_more'] . '</a>';

Change it to:

echo " <a href=\"#\" onclick=\"window.open('" . $sdurl . "plugins/p2_news/poparticle.php?p2_articleid=" . $article['articleid'] . "', '_blank', ' width=450,height=600,toolbar=0,menubar=0,resizable =0,location=0,status=0,scrollbars=0,directories=0 ');return false\">" . $p2_language['read_more'] . "</a>";



There ya go! this tutorial will allow a user to create the read more link to create a pop window with just the article itself.

***NOTE: this is only ment for an original news plugin (Not a cloned one)!! It will work cloned, when this code is placed before a clone is made.

Attached below you'll find the file -- just incase you're having copy and paste issues (or are just too lazy) :P

Hug_It
08-19-2005, 07:50 PM
I had added the short tutorial for the pop window (like you asked) before the site went down but when it came back online it was gone. This is much better anyway!

[Placed by Abcohen]
but if you just want to open another browser window try this...

Just add a "target=_blank" to the read more link in news.php.

On line 406:
* *echo ' <a href="' . RewriteLink('index.php?categoryid=' . $categoryid . '&p2_articleid=' . $article['articleid']) . '">' . $p2_language['read_more'] . '</a>';

Change it to:
* *echo ' <a href="' . RewriteLink('index.php?categoryid=' . $categoryid . '&p2_articleid=' . $article['articleid']) . '" target="_blank">' . $p2_language['read_more'] . '</a>';

**This would be instead of the tutorial**
[Thanks Hug_It for the original post of this]

peterb
08-21-2005, 04:13 AM
Originally posted by abcohen@Aug 19 2005, 11:04 AM
in news.php.

On line 406:
Change it to:

echo '<a href="#" onclick="javascript:window.open(' . RewriteLink(' . $sdurl . 'plugins/p2_news/poparticle.php?p2_articleid=' . $article['articleid'] . ') . '\', \'_blank\', \' width=450,height=600,toolbar=0,menubar=0,resizable =0,location=0,status=0,scrollbars=0,directories=0\ '); return false;">' . $p2_language['read_more'] . '</a>';


Hi,

Are you sure this code is correct? I keep getting a parse error:
parse error, unexpected T_STRING in /home/me/www.mysite.com/docs/plugins/p2_news/news.php on line 406

thanks,
PeterB

peterb
08-21-2005, 06:31 AM
Hi,

THIS is the correct code for line 406:
echo '<a href="#" onclick="javascript:window.open(' . RewriteLink . '(' . $sdurl . 'plugins/p2_news/poparticle.php?p2_articleid=' . $article['articleid'] . ')' . '\', \'_blank\', \' width=450,height=600,toolbar=0,menubar=0,resizable =0,location=0,status=0,scrollbars=0,directories=0\ '); return false;">' . $p2_language['read_more'] . '</a>';

You'll notice the '(' after RewriteLink .

Thanks,
peterb

abcohen
08-21-2005, 06:47 PM
Thats not 100% correct -- it seems that the rewrite code cant work here... I've updated my tutorial with the correct code... if you look at your source your'll see it says RewriteLink(www.domainname.com~blah~blah) which isnt correct...

peterb
08-21-2005, 09:28 PM
Originally posted by abcohen@Aug 21 2005, 12:47 PM
Thats not 100% correct -- it seems that the rewrite code cant work here... I've updated my tutorial with the correct code...* if you look at your source your'll see it says RewriteLink(www.domainname.com~blah~blah)** which isnt correct...
788


Well, at least my solution fixed the parse error!! :blink: :D I didn't try it yet to see if the Link actually worked. :(

Is the poparticle.php file still the same?
Thanks,
peterb

abcohen
08-24-2005, 03:03 AM
Originally posted by peterb@Aug 21 2005, 05:28 PM
Well, at least my solution fixed the parse error!! :blink:* :D* I didn't try it yet to see if the Link actually worked.* :(

Is the* poparticle.php file still the same?
Thanks,
peterb
793

yup nothing else changed.

mutley
10-29-2005, 04:14 PM
is there a way of getting one of the main menu links to open in a new window?

i have a site that I'm looking to develop with subdreamer, but from what i have seen so far all the main menu links open in the same window, what i want to do is have a link to a forum that will open up in a new window

it probably is a case of just adding the target="_blank" to somewhere, but I'm not sure where?

any help gratefully received

Paul

abcohen
10-29-2005, 10:05 PM
<div class='quotetop'>QUOTE(mutley &#064; Oct 29 2005, 12&#58;14 PM) 1944</div>
is there a way of getting one of the main menu links to open in a new window?

i have a site that I&#39;m looking to develop with subdreamer, but from what i have seen so far all the main menu links open in the same window, what i want to do is have a link to a forum that will open up in a new window

it probably is a case of just adding the target="_blank" to somewhere, but I&#39;m not sure where?

any help gratefully received

Paul
[/b]
http://www.subdreamer.com/forum/showthread...highlight=learn (http://www.subdreamer.com/forum/showthread.php?t=5150&highlight=learn)
paul read that.

mutley
10-31-2005, 08:27 PM
Thankyou for that

docc
12-27-2005, 11:55 PM
I would like to use the article in a new window, but im not sure where to past the new code on news.php, my line 406 doesnt match whats shown here. I am ne to php.... :(

abcohen
12-28-2005, 03:18 AM
this was for the Pro version only... Lite version might not have the same code.