Author Topic: Redirect to next image after vote *solved*  (Read 14617 times)

0 Members and 1 Guest are viewing this topic.

Offline trez

  • Hero Member
  • *****
  • Posts: 613
    • View Profile
    • blog / photography
Redirect to next image after vote *solved*
« on: January 23, 2006, 05:05:06 PM »
Hello ;)

I love 4images, i've installed over 30 MOD's and i'am glad that there are people like V@no, TheOracle & Acid, that are providing us with interesting and usefull MOD's

But i'am still a PHP newbie, and i can't get some special thing work.

Q: Is it possible to redirect the user, after he submitted a vote, to the next image in the category, if there is one? By default, it takes you again to the image you've just voted for. Any way to change this?

edit: I've searched the whole forum for "rating" and "redirect", but i don't found an answer - if there is a similiar topic please excuse :)

I'am using RadioButtons as a rate form, e.g.:

Code: [Select]
<FORM action={self} method=post target=_top>

                        <TD width="62"></TD>
                        <TD align=middle width="319"> <table border="0" cellspacing="1" width="100%">
                            <tr>
                              <td align="center">1</td>
                              <td align="center">2</td>
                            </tr>
                            <tr>

                              <td><input onclick=submit() type="radio" value="1" name="rating"></td>
                              <td><input onclick=submit() type="radio" value="2" name="rating"></td>                   
                            </tr>

                          </table></TD>

 <input type="hidden" name="action" value="rateimage">
  <input type="hidden" name="id" value="{image_id}">
</FORM>


So, thinking logically i have to use these tags:

Code: [Select]
{if next_image_url}<a href="{next_image_url}">{endif next_image_url}
{if next_image_url}</a>{endif next_image_url}

But anything i tried is not working, maybe i have to change some comang in a *.php file? This is very important for me, so i would be very happy if anyone could help me solve my problem.  :) Thanks for your time

edit2: Looks like there is a diffeerence between FIrefox and IE related to this. I put the {rate_form} before the image, like this:

Code: [Select]
{if next_image_url}<a href="{next_image_url}">{endif next_image_url}
   {rate_form} {image}
{if next_image_url}</a>{endif next_image_url}

Now, Firefox is taking me to the next image after i rate it, but IE doesn't - Please help me :)


Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Redirect question *please help*
« Reply #1 on: January 24, 2006, 01:28:41 AM »
Just an idea, dont know if it actualy would work, but what if you replace {self} in rate_form.html with {next_image_url} ?
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline TheOracle

  • Hero Member
  • *****
  • Posts: 875
    • View Profile
Re: Redirect question *please help*
« Reply #2 on: January 24, 2006, 03:22:25 AM »
And since the {self} tag is being used from your includes/page_header.php file (and, in case the first solution has no results),

find :

Quote

$site_template->register_vars(array(
  "media_url" => MEDIA_PATH,


add above :

Quote

$act_key = array_search($image_id, $image_id_cache);
$next_image_id = (isset($image_id_cache[$act_key + 1])) ? $image_id_cache[$act_key + 1] : 0;


Then, find :

Quote

"self" => $site_sess->url($self_url),


add right below :

Quote

"next_image_url" = $site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$next_image_id.((!empty($mode)) ? "&amp;mode=".$mode : "")),


Then, from your posted template file's readings above, as V@no stated, replace the {self} tag with {next_image_url}.

Note: This has not been tested.

[ Topic edted ]

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Redirect question *please help*
« Reply #3 on: January 24, 2006, 05:15:47 AM »
@TheOracle:
It will not work, because page_header.php being included before information about next image being readed from database.
Also, I don't think my method will work either...unless 4images v1.7 used..(haven't test it either :))
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline trez

  • Hero Member
  • *****
  • Posts: 613
    • View Profile
    • blog / photography
Re: Redirect question *please help*
« Reply #4 on: January 24, 2006, 12:10:28 PM »
Thank you for your help i appreciate it. So, for the first solution i get an "The requested URL /xxx/method=post was not found on this server"
. The second solution is also not working, but at least it gives me parse-errors in the lines (TheOracle, i've changed page_header.php, right?)

The really strange is that, in Firefox everything is working fine, only IE makes a problem *not the first one  :twisted:*. Maybe there is somewhere an error in my whole rate form? I"ve sentenced that Firefox is handling script errors and "strange html writing" better than IE. So this is my whole rate_forrm:

Code: [Select]
<FORM action={self} method=post target=_top>
  <TABLE borderColor=#000000 cellSpacing=0 cellPadding=0 width=450>
    <TBODY>
      <TR vAlign=top>
        <TD align=top width="440"> <TABLE borderColor=#000000 cellSpacing=0 cellPadding=1 width="100%"  class="head2clubsmain">
            <TBODY>
              <TR vAlign=top>
                <TD align=middle> <TABLE width=445 border=0>
                    <TBODY>
                      <TR>
                        <TD align=middle colSpan=3 width="445"> <b>Гласувай за тази снимка!</b></font></TD>
                      </TR>
                      <TR>
                        <TD width="62"></TD>
                        <TD align=middle width="319"> <table border="0" cellspacing="1" width="100%">
                            <tr>
                              <td align="center">1</td>
                              <td align="center">2</td>
                              <td align="center">3</td>
                              <td align="center">4</td>
                              <td align="center">5</td>
                              <td align="center">6</td>
                              <td align="center">7</td>
                              <td align="center">8</td>
                              <td align="center">9</td>
                              <td align="center">10</td>
                              <td align="center">11</td>
                              <td align="center">12</td>
                            </tr>
                            <tr>


                              <td><input onclick=submit() type="radio" value="1" name="rating" ></td>
                              <td><input onclick=submit() type="radio" value="2" name="rating"></td>
                              <td><input onclick=submit() type="radio" value="3" name="rating"></td>
                              <td><input onclick=submit() type="radio" value="4" name="rating"></td>
                              <td><input onclick=submit() type="radio" value="5" name="rating"></td>
                              <td><input onclick=submit() type="radio" value="6" name="rating"></td>
                              <td><input onclick=submit() type="radio" value="7" name="rating"></td>
                              <td><input onclick=submit() type="radio" value="8" name="rating"></td>
                              <td><input onclick=submit() type="radio" value="9" name="rating"></td>
                              <td><input onclick=submit() type="radio" value="10" name="rating"></td>
                              <td><input onclick=submit() type="radio" value="11" name="rating"></td>
                              <td><input onclick=submit() type="radio" value="12" name="rating"></td>




                            </tr>

                          </table></TD>
                        <TD width="29"></TD>
                      </TR>
                      <TR>
                        <TD width="62"><FONT color=#006699 size=2><B>NOT</B></FONT></TD>
                        <TD align=middle width="319"> <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
                            <TBODY>
                              <center><img src="{template_url}/images/hotornotback.gif" border="0" alt="" /></center>
                            </TBODY>
                          </TABLE></TD>
                        <TD width="29"><FONT color=#cc3300 size=2><B>HOT</B></FONT></TD>
                      </TR>
                    </TBODY>
                  </TABLE></TD>
              </TR>
            </TBODY>
          </TABLE></TD>
      </TR>
    </TBODY>
  </TABLE>
  <input type="hidden" name="action" value="rateimage">
  <input type="hidden" name="id" value="{image_id}">
</FORM>


I'am sitting hours on searching google for an error but i can't find it. Hope you help me trough this guys, because your skills are much higher than mine :)

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Redirect question *please help*
« Reply #5 on: January 24, 2006, 02:54:56 PM »
and what address does it show for the form action after opening the page? (look in page source)

P.S. your site has a broken link in the copyright to 4homepages.de site.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline trez

  • Hero Member
  • *****
  • Posts: 613
    • View Profile
    • blog / photography
Re: Redirect question *please help*
« Reply #6 on: January 24, 2006, 04:12:19 PM »
It shows for example at image 75
Code: [Select]
<a href="./details.php?image_id=76">   
<FORM action=details.php?image_id=75 method=post target=_top>

... before i click on a rating option

You can access my site using username "test3" and password "1234" on http://www.zapomnime.com or http://www.ggrec.com/zapomnime2/


edit:
PS: I know about the broken link, have some problems with the footer, because i have the menue on the right side, i will fix it before my site goes ofifcially online (have to include the footer on 244 sites  :x )


Offline trez

  • Hero Member
  • *****
  • Posts: 613
    • View Profile
    • blog / photography
Re: Redirect question *please help*
« Reply #7 on: January 24, 2006, 04:18:22 PM »
I thought maube i would be better if i post the whole -code what is generated for the details page.

From the source:
Code: [Select]



                <td width="1" class="bordercolor" valign="top"><img src="./templates/default/images/spacer.gif" width="1" height="1" alt="" /></td>
                <td width="18" valign="top"><img src="./templates/default/images/spacer.gif" width="18" height="18" alt="" /></td>
                <td width="450" valign="top"><br />

                  <table width="100%" border="0" cellspacing="0" cellpadding="1">
                    <tr>
                      <td class="bordercolor">
                        <table width="100%" border="0" cellspacing="0" cellpadding="3">

                          <tr valign="top">
                            <td class="row1">
  Предни снимки:<br />
                              <b><a href="./details.php?image_id=74" onMouseOver="a('IMG 0526');return true"
onMouseOut="b()">IMG 0526</a></b>
  <br /><a href="./details.php?image_id=74"><img src="./data/thumbnails/11/IMG_0526.JPG" border="1"></a>
  &nbsp;</td>
                            <td align="right" class="row1">
  &nbsp;Следващите снимки:<br />

                              <b><a href="./details.php?image_id=76">IMG 0529</a></b>
  <br /><a href="./details.php?image_id=76"><img src="./data/thumbnails/11/IMG_0529.JPG" border="1"></a>
  </td>
                          </tr>
                        </table>
                      </td>
                    </tr>
                  </table>


                  <b class="title">IMG 0527</b> <sup class="new">ново</sup> <img src="./templates/default/images/7.gif" alt="" />
 
                                    <div align="center">
   




<a href="./details.php?image_id=76">   
<FORM action=details.php?image_id=75 method=post target=_top>
  <TABLE borderColor=#000000 cellSpacing=0 cellPadding=0 width=450>
    <TBODY>

      <TR vAlign=top>
        <TD align=top width="440"> <TABLE borderColor=#000000 cellSpacing=0 cellPadding=1 width="100%"  class="head2clubsmain">
            <TBODY>
              <TR vAlign=top>
                <TD align=middle> <TABLE width=445 border=0>
                    <TBODY>
                      <TR>
                        <TD align=middle colSpan=3 width="445"> <b>Гласувай за тази снимка!</b></font></TD>

                      </TR>
                      <TR>
                        <TD width="62"></TD>
                        <TD align=middle width="319"> <table border="0" cellspacing="1" width="100%">
                            <tr>
                              <td align="center">1</td>
                              <td align="center">2</td>

                              <td align="center">3</td>
                              <td align="center">4</td>
                              <td align="center">5</td>
                              <td align="center">6</td>
                              <td align="center">7</td>
                              <td align="center">8</td>

                              <td align="center">9</td>
                              <td align="center">10</td>
                              <td align="center">11</td>
                              <td align="center">12</td>
                            </tr>
                            <tr>

                              <td><input onclick=submit() type="radio" value="1" name="rating" ></td>
                              <td><input onclick=submit() type="radio" value="2" name="rating"></td>
                              <td><input onclick=submit() type="radio" value="3" name="rating"></td>
                              <td><input onclick=submit() type="radio" value="4" name="rating"></td>
                              <td><input onclick=submit() type="radio" value="5" name="rating"></td>
                              <td><input onclick=submit() type="radio" value="6" name="rating"></td>
                              <td><input onclick=submit() type="radio" value="7" name="rating"></td>
                              <td><input onclick=submit() type="radio" value="8" name="rating"></td>

                              <td><input onclick=submit() type="radio" value="9" name="rating"></td>
                              <td><input onclick=submit() type="radio" value="10" name="rating"></td>
                              <td><input onclick=submit() type="radio" value="11" name="rating"></td>
                              <td><input onclick=submit() type="radio" value="12" name="rating"></td>




                            </tr>

                          </table></TD>

                        <TD width="29"></TD>
                      </TR>
                      <TR>
                        <TD width="62"><FONT color=#006699 size=2><B>NOT</B></FONT></TD>
                        <TD align=middle width="319"> <TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
                            <TBODY>
                              <center><img src="./templates/default/images/hotornotback.gif" border="0" alt="" /></center>
                            </TBODY>

                          </TABLE></TD>
                        <TD width="29"><FONT color=#cc3300 size=2><B>HOT</B></FONT></TD>
                      </TR>
                    </TBODY>
                  </TABLE></TD>
              </TR>
            </TBODY>
          </TABLE></TD>

      </TR>
    </TBODY>
  </TABLE>
  <input type="hidden" name="action" value="rateimage">
  <input type="hidden" name="id" value="75">
</FORM>


 <!-- Template file for JPG Files -->
<img src="./data/media/11/IMG_0527.JPG" border="1" alt="IMG 0527" width="600" height="450" /><br />
</a>
Рейтинг до момента: 7.00 (1 Гласа)<img src="./templates/default/images/7.gif" alt="" />

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Redirect question *please help*
« Reply #8 on: January 25, 2006, 12:31:03 AM »
Did you try the method I've posted above? (without any other changes)
Cause, what I see right now, has no changes posted above.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline trez

  • Hero Member
  • *****
  • Posts: 613
    • View Profile
    • blog / photography
Re: Redirect question *please help*
« Reply #9 on: January 25, 2006, 01:04:33 AM »
Yes, as i said, i tried it and i get an 404 ( "The requested URL /xxx/method=post was not found on this server" )

Strange that getting such a "small" function to work is so difficult  :roll: :roll:
Any other ideas?

georgi

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Redirect question *please help*
« Reply #10 on: January 25, 2006, 01:16:16 AM »
The problem is that next image is unknown at the moment rate_form.html template is being parsed.

P.S. "get error 404" is not very usefull information, knowing exactly what url it was trying to access is more important, that's why I'd like to see the changes in action, so I could use some special tools to see the headers and such.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline trez

  • Hero Member
  • *****
  • Posts: 613
    • View Profile
    • blog / photography
Re: Redirect question *please help*
« Reply #11 on: January 25, 2006, 02:55:07 AM »
Ok, i try to explain the error better  8)

When i replace {self} with {next_image_url} in the rate_form i get 2 different errors:

When i vote in FIREFOX, it takes me to the next image, but it dont registers the vote in the database

When i vote in IE, i get the standart IE "The Page cannot be found" error message. The page IE try to open is

Code: [Select]
http://www.ggrec.com/zapomnime2/method=post?rating=2&action=rateimage&id=339
I hope that helps  :roll: :roll:

edit: "zapomnime2" is my default 4images folder

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Redirect question *please help*
« Reply #12 on: January 25, 2006, 03:13:20 AM »
Ok, here is what I just did, tested and it worked on a fresh v1.7.1:
in details.php move
Code: [Select]
show_image($image_row, $mode, 0, 1);below
Code: [Select]
unset($next_prev_cache);And in rate_form.html replace {self} with:
a) if you applyed fix [1.7.1] Conditional tags inside other conditional tags + {ifno ...}{endifno ...}:
Code: [Select]
{if next_image_url}{next_image_url}{endif next_image_url}{ifno next_image_url}{self}{endifno next_image_url}
b) if you cant use {ifno ..} tags, then replace with this:
Code: [Select]
{if next_image_url}{next_image_url}&{endif next_image_url}{self}The b) version will produce "double" url, but I've tested on IE and FF and it worked just fine. So, version a) is preferable

Both of the methods ensures that if its last image (no next image avalable), then it will stay on current image.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline trez

  • Hero Member
  • *****
  • Posts: 613
    • View Profile
    • blog / photography
Re: Redirect question *please help*
« Reply #13 on: January 25, 2006, 04:09:33 AM »
its working!  :D :D

its 5 in the morning but you made my day  :lol: владелец спасибо!