Go Back   Pligg CMS Forum > Pligg Development > Modification Tutorials

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-17-2007, 03:35 AM
Pligg Donor
 
Join Date: Jan 2007
Location: Italy
Posts: 24
Thanks: 10
Thanked 14 Times in 7 Posts
Voting from external frame

Hello all

I'm new with Pligg (it's about 10 days I'm working with).
I've implemented my site www.vincipremi.it with Pligg: I have modified Mollio template (but I have some problem in IE) and a deep translation in italian (translation is still an hell ;-) ).
So, sorry if site is not complete and not tested but is online since a couple of hours (If you can't see it probably is due a DNS stuff, try later!!).

I have implemented a voting system in frame when you click on link to go to the external site.

I've seen the solution from qxygene (good job!) but I think is more important to permit user to vote from outside because we hope he returns on site after viewing and voting linked site.

Go to www.vincipremi.it and try to clik on link "Vai alla notizia direttamente" from one of the articles and see if that is what you mean!
You can vote clicking on button "VOTALO!" and you can see vote changing. If you are not logged you are redirected to login, but if you are logged in and try to revote, button change state and said that you have already voted.

If you are interested I have modified some files:
2 files created for the external frame
1 js ajax
1 template file
2 lib php

With this modified code you can link in normal mode through admin panel/Outgoing links -> "url, title or id" , but I have added "frame" that you can use to call external site with this method.
Probably there are other methods to do this (I'm not so good programmer), and coding could be better!!

If you want I can share my solution.

Thanks all for pligg...and sorry for my "italianenghlish"!!
bye
Ram
Reply With Quote
The Following 3 Users Say Thank You to ramos67 For This Useful Post:
  #2 (permalink)  
Old 02-04-2007, 02:57 PM
Casual Pligger
 
Join Date: Jan 2007
Posts: 46
Thanks: 5
Thanked 1 Time in 1 Post
Good Work!

Ciao! I'm also "playing" with pigg from some weeks, I'm really interested oon your good work on the external link frame, can you share it?? Many thanks!
Reply With Quote
  #3 (permalink)  
Old 02-04-2007, 05:31 PM
Pligg Donor
 
Join Date: Jan 2007
Location: Italy
Posts: 24
Thanks: 10
Thanked 14 Times in 7 Posts
Here's my code

Hi,
this code is working for me, and probably you could do better (querystring etc), but I've done it quickly...

Here's attached all the modified files:

go_ext.php and go_ext_top.php are the frame called by our story.

go_ext_top.php : you can see which field are used by the function "votalo" that is inside xmlhttp.js. This file is the top part of the frame.
Don't change the tags <span id="butvotazione"> and other span because these are referenced by the code in xmlhttp.js.

xmlhttp.js : contains new function "votalo" similar to menealo.

link_summary.tpl : I use mollio template. Search "QUI RAM" in the code and see <a href="{$url}{$link_frameram_vote}" . I extended $url.
Probably I've changed this file, but you can use the original and change in the file where there's comment "QUI RAM"

html1.php
: search "RAMMOD". I changed calling page (standard is out.php, I call go_ext.php that is the frame containing go_ext_top.php passing parameters.

link.php: search MOD RAM . I insert the new keyword "frame" that is used in the admin panel for outgoing link. Remember to change this in the panel, otherwise
out.php will be called.

Also you need some button graphics in dir /img/vote (as you want)

Tell me your site when you implement this , please.

I hope this help!

ciao! RAM

[UPD]For version 9.8.2 go to page 2 to download. This is for beta9.0
Attached Files
File Type: zip mod_vote_ext.zip (19.5 KB, 136 views)
__________________
www.vincipremi.it - pligg powered

Last edited by ramos67; 01-06-2008 at 07:19 AM.. Reason: Older version
Reply With Quote
The Following 4 Users Say Thank You to ramos67 For This Useful Post:
  #4 (permalink)  
Old 02-27-2007, 06:41 AM
New Pligger
 
Join Date: Sep 2006
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
ramos67 thanks for your good work! I implement on http://wins.ro and work like a charm.


anonymous vote doesn't work from frame.
in website works but in frame not... maybe it is something wrong in xmlhttp.js
__________________
Daily Fun is my job

Last edited by justelite; 02-27-2007 at 07:26 AM..
Reply With Quote
  #5 (permalink)  
Old 02-27-2007, 03:04 PM
Pligg Donor
 
Join Date: Jan 2007
Location: Italy
Posts: 24
Thanks: 10
Thanked 14 Times in 7 Posts
Anonymous vote

hi,
probably the problem is in function votalo in xmlhttp.js.
In my site anonymous vote is disabled but you can try this mod:

This is the original votalo function

PHP Code:
function votalo (useridhtmlidmd5value)
{
      if (
xmlhttp) {
        
url "menealo.php";
        var 
content "id=" id "&user=" user "&md5=" md5 "&value=" value;
        
anonymous_vote false;
        if (
anonymous_vote == false && user == '0') {
            
parent.window.location="login.php?return="+location.href;
        } else {
            
mnmxmlhttp = new myXMLHttpRequest ();
            if (
mnmxmlhttp) {
                
mnmxmlhttp.open ("POST"urltrue);
                
mnmxmlhttp.setRequestHeader ('Content-Type',
                           
'application/x-www-form-urlencoded');
    
                
mnmxmlhttp.send (content);
                
errormatch = new RegExp ("^ERROR:");
    
                
mnmxmlhttp.onreadystatechange = function () {
                    if (
mnmxmlhttp.readyState == 4) {
                        
mnmString mnmxmlhttp.responseText;
                        if (
mnmString.match (errormatch)) {
                            
mnmString mnmString.substring (6mnmString.length);
                            
// myclearTimeout(row);
                            // resetrowfull(row);
                            
changevotalo (usertrue);
                        } else {
                            
changevotalo (userfalse);
                        }
                    }
                }
            }
        }
    }    

Try with this one:
PHP Code:
function votalo (useridhtmlidmd5value)
{
      if (
xmlhttp) {
        
url "menealo.php";
        var 
content "id=" id "&user=" user "&md5=" md5 "&value=" value;
            
mnmxmlhttp = new myXMLHttpRequest ();
            if (
mnmxmlhttp) {
                
mnmxmlhttp.open ("POST"urltrue);
                
mnmxmlhttp.setRequestHeader ('Content-Type',
                           
'application/x-www-form-urlencoded');
    
                
mnmxmlhttp.send (content);
                
errormatch = new RegExp ("^ERROR:");
    
                
mnmxmlhttp.onreadystatechange = function () {
                    if (
mnmxmlhttp.readyState == 4) {
                        
mnmString mnmxmlhttp.responseText;
                        if (
mnmString.match (errormatch)) {
                            
mnmString mnmString.substring (6mnmString.length);
                            
// myclearTimeout(row);
                            // resetrowfull(row);
                            
changevotalo (usertrue);
                        } else {
                            
changevotalo (userfalse);
                        }
                    }
                }
            }
        
    }    

I hope this can help you. Remember this is UNTESTED.

bye RAM
__________________
www.vincipremi.it - pligg powered
Reply With Quote
The Following User Says Thank You to ramos67 For This Useful Post:
  #6 (permalink)  
Old 02-28-2007, 08:57 AM
New Pligger
 
Join Date: Sep 2006
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts
Now voting from frame works for anonymous !

thanks!
__________________
Daily Fun is my job
Reply With Quote
  #7 (permalink)  
Old 02-28-2007, 06:44 PM
Pligg Donor
 
Join Date: Jan 2007
Location: Italy
Posts: 24
Thanks: 10
Thanked 14 Times in 7 Posts
well!


but probably the best solution is from this post so you can enable and disable through admin panel

bye RAM
__________________
www.vincipremi.it - pligg powered

Last edited by ramos67; 02-28-2007 at 06:51 PM..
Reply With Quote
  #8 (permalink)  
Old 03-06-2007, 08:33 PM
peppolone's Avatar
Pligg Donor
Pligg Version: 995-54
Pligg Template: upnews.it
 
Join Date: Dec 2006
Location: rome
Posts: 124
Thanks: 2
Thanked 35 Times in 13 Posts
Hi ramos,(anch'io italiano)
I notice the frame <iframe src="<? echo $go; ?>" is in the go_ext and also in the go_ext_top.
I set the height of the frametop to 40px and so i seen two bottom frame.
If you open your story u can listen two audio

The function votalo doesn't work with pligg 9.1 , the function menealo now is function vote:
PHP Code:
function vote (user, id, htmlid, md5, value)
{
      if (xmlhttp) {
        url = "<?php echo $my_base_url.$my_pligg_base?>/vote.php";
        var mycontent = "id=" + id + "&user=" + user + "&md5=" + md5 + "&value=" + value;
        anonymous_vote = <?php echo anonymous_vote?>;
        if (anonymous_vote == false && user == '0') {
            window.location="<?php echo $my_base_url.$my_pligg_base?>/login.php?return="+location.href;
        } else {
            mnmxmlhttp[htmlid] = new myXMLHttpRequest ();
            if (mnmxmlhttp) {
                mnmxmlhttp[htmlid].open ("POST", url, true);
                mnmxmlhttp[htmlid].setRequestHeader ('Content-Type',
                           'application/x-www-form-urlencoded');
    
                mnmxmlhttp[htmlid].send (mycontent);
                errormatch = new RegExp ("^ERROR:");
    
                target1 = document.getElementById ('mnms-' + htmlid);
    
                mnmPrevColor[htmlid] = target1.style.backgroundColor;
                //target1.style.background = '#c00';
                //target1.style.backgroundColor = '#FF9D9F';
                mnmxmlhttp[htmlid].onreadystatechange = function () {
                    if (mnmxmlhttp[htmlid].readyState == 4) {
                        mnmString[htmlid] = mnmxmlhttp[htmlid].responseText;
                        if (mnmString[htmlid].match (errormatch)) {
                            mnmString[htmlid] = mnmString[htmlid].substring (6, mnmString[htmlid].length);
<?php if(Voting_Method == 1){
    echo 
"                            changemnmvalues (htmlid, true);";
}
?>
                        } else {
<?php if(Voting_Method == 2){
    echo 
"                                var mySplitResult = mnmString[htmlid].split('~');\n";
    echo 
"                            target3 = document.getElementById ('mnmlink-' + htmlid);\n";
    echo 
"                            target3.style.width = mySplitResult[0] + 'px';\n";
    echo 
"                            target4 = document.getElementById ('mnma-' + htmlid);\n";
    echo 
"                            target4.innerHTML = mySplitResult[1];\n";
    echo 
"                            target5 = document.getElementById ('mnmb-' + htmlid);\n";
    echo 
"                            target5.innerHTML = mySplitResult[2];\n";
    echo 
"                            target7 = document.getElementById ('mnms-' + htmlid);\n";
    echo 
"                            target7.className = 'star-rating-noh';\n";
    
}
?>
<?php 
if(Voting_Method == 1){
    echo 
"                            changemnmvalues (htmlid, false);";
}
?>
                        }
                    }
                }
            }
        }
    }
}
Can u help me to write new function votalo?
Is possible use EVB for this mod?
Also my enlgish is maccheronico!

Last edited by peppolone; 03-07-2007 at 01:12 AM..
Reply With Quote
  #9 (permalink)  
Old 03-07-2007, 05:55 AM
Pligg Donor
 
Join Date: Jan 2007
Location: Italy
Posts: 24
Thanks: 10
Thanked 14 Times in 7 Posts
You are right

Ciao Peppolone,

You are right, probably I've forgotten the <iframe src="<? echo $go; ?> in go_ext_top.
I can't test now but you can delete this iframe from go_ext_top.php because this is called already in go_ext.php.

For version 9.1 I've seen that function is changed, but my installation is 9beta. I don't plan to upgrade now bbecause I'm busy, but as soon as I can I'll try to modify this.
I can change the function and pass it to you so you cant test.

bye RAM

UPDATE: you can delete the iframe in go_ext_top. I've tested it. thanks
__________________
www.vincipremi.it - pligg powered

Last edited by ramos67; 03-07-2007 at 06:12 AM.. Reason: testing mod
Reply With Quote
  #10 (permalink)  
Old 08-21-2007, 03:18 AM
Constant Pligger
Pligg Version: Pligg 9.9
Pligg Template: Custom
 
Join Date: Jul 2007
Location: Ottawa, Ontario
Posts: 156
Thanks: 27
Thanked 9 Times in 9 Posts
Can someone point out how to implement this using pligg 9.7. The external frame is actually working. The problems are.
The vote button is not fonctional, and doesn't even put the number of votes on it.

The url after go_ext.php?go= is all messed up but working(it takes you to the site desired).

The title of the page that appears is www. EDIT: You can change the title from the go_ext.php file at line 16.

Any help here? I think menealo isn't used in 9.7. So I think it has to do with xmlhttp.php/.js.

Edit2: In 9.7 do we use both xmlhttp.php and xmlhttp.js or are they the same?

Last edited by Unknown; 08-21-2007 at 04:01 AM.. Reason: 1 solution found
Reply With Quote
Reply

Thread Tools
Display Modes
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Similar Threads
Thread Thread Starter Forum Replies Last Post
[MOD] External Frame qxygene Modification Tutorials 19 06-25-2008 04:09 AM
External Voting Button Setup MarekSpace General Help 0 01-18-2008 02:16 PM
Voting Error on page jitu "Mollio-Beat" 7 11-02-2007 05:46 AM
[Fixed] Voting and login problems with latest build (702) silversow Bug Report 2 02-14-2007 04:13 AM
api, evb, check_url and external voting hm2k General Help 2 11-20-2006 09:00 AM


Search Engine Friendly URLs by vBSEO 3.2.0