Author |
Message |
hanscom
Hangin' Around
Joined: Oct 16, 2003
Posts: 36
|
Posted:
Fri Apr 06, 2007 8:02 am |
|
Hi,
Is it possible to disable the link of the current page with javascript?
The link is in block-Test.php and the current page is in the Nuke Theme.
Regards,
Hans |
|
|
|
|
kguske
Site Admin
Joined: Jun 04, 2004
Posts: 6432
|
Posted:
Fri Apr 06, 2007 11:40 am |
|
|
|
|
hanscom
|
Posted:
Fri Apr 06, 2007 2:28 pm |
|
Yes, I have a block with several images that act as links. But if if one of the links is the current page, I don't want the image link to disappear, but become 'unclickable'.
Is it easier to accomplish this by using php? Can you give me a hint?
Thanks in advance,
Hans |
|
|
|
|
gregexp
The Mouse Is Extension Of Arm
Joined: Feb 21, 2006
Posts: 1497
Location: In front of a screen....HELP! lol
|
Posted:
Fri Apr 06, 2007 2:58 pm |
|
Well, if opinions are desired : PHP can be much better suited to do this rather then Javascript as PHP is server side, that means user cant disable it.
Heres a quick tip:
lets say I have a link to forums.html in a block:
$url=$_SERVER['PHP_SELF'];
//$url is now the url of the call, without the [ Only registered users can see links on this board! Get registered or login! ]
//Now we will search the url and tell it what to do if it doesnt find what we are looking for.
if (!eregi('forums[.]html',$url)){
echo "link that works because we didnt find forums.html in the url";
}else{
echo "link that doesnt work because we found it";
}
I left the brackets in place for a reason, yes it will work without them, but its better practice with characters that are not letters or numbers to treat them this way. I have also found that telling it to make sure that it does NOT find it works on more occasions then telling it to look for something.
More or less a personal preference. |
_________________ For those who stand shall NEVER fall and those who fall shall RISE once more!! |
|
|
|
hanscom
|
Posted:
Sat Apr 07, 2007 3:40 am |
|
In my case the block-Welcome.php contains:
<?php
if (eregi("block-Welcome.php",$PHP_SELF)) {
Header("Location: index.php");
die();
}
$content .="<a href=\"index.php\" title=\"To Starting Page\"><img src=\"logo.jpg\"></a>";
?>
How do I modify this to prevent loading the current page again with the tip of darklord? |
|
|
|
|
montego
Site Admin
Joined: Aug 29, 2004
Posts: 9457
Location: Arizona
|
Posted:
Sat Apr 07, 2007 8:33 am |
|
I think we have to know more about you mean exactly by "current page". Are you linking to various modules, or are you within a module and it is producing pages and this is where you want this block to respond to? Also, give more examples of the links so we can get a better idea of what you are wanting to do. |
_________________ Where Do YOU Stand?
HTML Newsletter::ShortLinks::Mailer::Downloads and more... |
|
|
|
hanscom
|
Posted:
Sat Apr 07, 2007 9:07 am |
|
Ok, my website is [ Only registered users can see links on this board! Get registered or login! ] and in the modules folder I have a
subfolder Html with several html pages. Some blocks link to those pages.
The main page when entering the site is in Dutch text. The 3rd flag (Dutch) also
links to the main page(index.php). When the main page is visible I want the link
of the Dutch flag to be disabled but still visible. If possible the same with the
other blocks when their linked pages are visible.
The code for the Dutch flag block is:
<p align="center">
<a href="index.php"> <img border="0" src="LaCauserie/holflag.jpg">
And the code for the other flags:
<p align="center">
<a href="modules.php?name=Html
&page=eng-text.html"> <img border="0" src="LaCauserie/engflag.jpg">
I hope this info will help.
Regards, Hans |
|
|
|
|
hanscom
|
Posted:
Tue Apr 10, 2007 3:44 am |
|
Another idea.
I want to change the content of a block by updating the mysql table, but nothing
happens and I get no errors. Is there somethig wrong with the script?
The script:
<?php
$con = mysql_connect("localhost","root","xxxx");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("nuke", $con);
mysql_query("UPDATE nuke_blocks SET content = '<img src='logo.jpg'>' WHERE title = 'Logo'");
mysql_close($con);
?>
Hans |
|
|
|
|
evaders99
Former Moderator in Good Standing
Joined: Apr 30, 2004
Posts: 3221
|
Posted:
Tue Apr 10, 2007 9:19 pm |
|
|
|
|
hanscom
|
Posted:
Wed Apr 11, 2007 2:33 am |
|
Sorry, I don't understand.
Can you give an example to update a table?
TIA |
|
|
|
|
evaders99
|
Posted:
Wed Apr 11, 2007 4:38 pm |
|
Code:
include_once("mainfile.php");
$db->sql_query("UPDATE nuke_blocks SET content = '<img src='logo.jpg'>' WHERE title = 'Logo'");
|
If this is a standalone file, in the nuke root folder, that is all the code you need. Nuke should set up the correct database connection and you just need to use $db->sql_query instead of mysql_query |
|
|
|
|
|