PDA

View Full Version : my addon text_archive links to comment


jdleung
07-22-2006, 08:17 AM
I add comment count following its image name, and I also want to make link to the comment form when click the count number. it's easy to do so if using individual comment page. but I'm using a popup form in the front page.

how can I click the link in archive page and then goes to the front page and popup the comment form?

here you can have a look what I did
http://www.jdleungs.com/index.php?x=browse&pagenum=1&style=1

thanks.

jdleung
07-22-2006, 11:24 PM
can anyone help? or it's impossible to do so?

GeoS
07-22-2006, 11:32 PM
By using anchor in links.

I.e. blablabla.com/index.php?showimage=my_id#anchor_name

And before comment form you just put <a name="anchor_name"></a> and it should solve your problem.

jdleung
07-22-2006, 11:42 PM
GeoS, it's easy to do so if using individual comment page, but the form cannot popup.

jdleung
07-22-2006, 11:51 PM
as you see, there has been an anchor since the site runs.

GeoS
07-23-2006, 09:22 PM
Please write more "simple" what you want to get? You want to scroll in poped up window?? It should also be possible thanks to anchor. Still I dont see problem.

jdleung
07-24-2006, 03:07 AM
Please write more "simple" what you want to get? You want to scroll in poped up window?? It should also be possible thanks to anchor. Still I dont see problem.
as you see, my text archive page is something like this:

2006-07-20
[22:25:17] 灯饰-Illuminations (1)
[22:23:41] 灯饰-Illuminations (0)
[22:10:07] 布景-Backcloth (0)
[22:09:17] 舞台灯光-Lighting (0)

click the image name goes to the image, and now I want to add one more link that click the comment count number and goes to the comment form.

I had tested the following link:
<a href="index.php?showimage=$image_id#addcomment" >($count_num)</a>

and also this:
<a href="index.php?showimage=$image_id#addcomment" onclick="flip('add-comment'); gotocomments(); return false;">($count_num)</a>

as you see on my site, the comment form is always hidden before visitor click its link.

so the two test links above only leads me to the image in the front page, but the form doesn't popup.

more "simple" seems more "complicated" :rolleyes:

one word " click the link on the archive page and goes to the front page and POPUP THE COMMENT FORM." :)

GeoS
07-24-2006, 06:45 PM
You have to add additional code to JS flip() function.

I.e. use #addcomment2 in URLs and then in flip funtion add at the end:

if(document.location.hash=='addcomment2')
{
document.getElementById('add-comment').style.display = 'block';
document.location.hash = 'addcomment';
}

I would do that in this way because I hate popups.

PS Code is not tested and may be buggy but generaly shows idea of solution.

jdleung
07-25-2006, 12:03 PM
GeoS, what I mean "popup" is just like the one on your site. click comment and show the form.

your suggestion cannot work.

more simple: for example, click a picture in the archive page on your site, and goes to the front page, at the same time show your comment form which is hidden.

thanks.

GeoS
07-25-2006, 06:39 PM
I just wrote that its only idea of working code.

The idea should work just like you want with small except. This code must be outside the function. Now I got a little more fresh mind. So:

if(document.location.hash=='addcomment2')
{
flip('addcomment',1);
}

function flip(rid,go)
{
current=(document.getElementById(rid).style.displa y == 'none') ? 'block' : 'none';
document.getElementById(rid).style.display = current;
if(go==1) document.location.hash = ((current!='none') ? rid : 'home');
}



Test it and if it doesnt work then change it.

jdleung
07-26-2006, 02:35 AM
it still can't work.

link in archive page
<a href='index.php?showimage=$image_id#addcomment2' onclick='flip('add-comment'); gotocomments(); return false;'>($comment_num)</a>

and I also test this
<a href='index.php?showimage=$image_id#addcomment2'</a>

scripts in front page
<script language='javascript' type='text/javascript'>
<!-- BEGIN
if(document.location.hash=='addcomment2')
{
flip('addcomment',1);
}

function flip(rid,go)
{

current=(document.getElementById(rid).style.displa y == 'none') ? 'block' : 'none';
document.getElementById(rid).style.display = current;
if(go==1) document.location.hash = ((current!='none') ? rid : 'home');
}
// End -->
</script>

must I also add this scripts in archive page? how to add js in php?

GeoS
07-26-2006, 03:05 PM
OK. Today in some free time Ill try to put it into the test template. If it starts to work then Ill put it for you on server to download.

jdleung
07-26-2006, 04:09 PM
thanks. :)

GeoS
07-26-2006, 10:59 PM
Script:
<script language='javascript' type='text/javascript'>
<!-- BEGIN
if(document.location.hash=='#addcomment2')
{
flip('addcomment',1);
}

function flip(rid,go)
{

current=(document.getElementById(rid).style.displa y == 'none') ? 'block' : 'none';
document.getElementById(rid).style.display = current;
if(go==1) document.location.hash = ((current!='none') ? rid : 'home');
}
// End -->
</script>

Link:
<a href='index.php?showimage=$image_id#addcomment2'</a>

It should work. Now I found next mistake - document.location.hash returns string with # at beginning.

jdleung
07-27-2006, 02:42 AM
it works. but the comment form cannot be hidden even I click to another photo.

at last, I found a mistake which make it works
current=(document.getElementById(rid).style.displa y == 'none') ? 'block' : 'none';

"displa y", correct it and it refuses to work again.:rolleyes:

jdleung
07-27-2006, 02:52 AM
there is another scripts before the form, need to change?

<script language='javascript' type='text/javascript'>
<!-- BEGIN
function gotocomments()
{
document.location = '#addcomment';
if (source.nodeType == 3) {
source = source.parentNode;
}
var id = source.href.split('#')[1];
var elem;
for (var i = 0; (elem = et_toggleElements[i]); i++) {
if (elem.id != id) {
elem.style.display = 'none';
} else {
elem.style.display = 'block';
}
}
// End -->
</script>
<script language='javascript' type='text/javascript'>flip('add-comment');</script>

GeoS
07-27-2006, 06:17 AM
So call in this if statement gocomments() instead of flip().

jdleung
07-27-2006, 07:30 AM
it's ok now. :)

the following script must be add before the form, and it will refuse to work if insert it at the begining of the page.

if(document.location.hash=='#addcomment2')
{
flip('add-comment'); gotocomments();
}

it still works ok when I tried to remove the following line
if(go==1) document.location.hash = ((current!='none') ? rid : 'home');

thanks, GeoS.

GeoS
07-27-2006, 11:27 AM
Cool that problem is solved. More or less code which I posted yesterday (my time) worked fine. I put it at bottom of page and still there was no problems.
Now it doesnt matter.