0

I need to run this code:

<font size='3'><b>
    <li class="icon-home">
        <a href="{U_INDEX}" accesskey="h">{L_INDEX}</a> <!-- BEGIN navlinks -->
        <strong>&#8249;</strong>
        <a href="{navlinks.U_VIEW_FORUM}">{navlinks.FORUM_NAME}</a><!-- END navlinks -->
    </li>
</b></font>

when the site is at index.php.

I have tried this:

<script type="text/javascript">
    $(document).ready(function () {
        if(window.location.href.indexOf("index.php") > -1) {
           document.write('//the above HTML');
        }
    });
</script>

I can't use php because I am using a html file. The above code just gave me the board links and nothing else. I need the links to show as well as the rest of the page.

Thanks for your help.

2 Answers 2

1

Instead of document.write you should use a div or another element as a placeholder

if (location.href.indexOf("/index.php") > -1 ) {
   document.getElementById("myPlaceHolder").innerHTML = '<font size="3"><b><li class="icon-home"><a href="{U_INDEX}" accesskey="h">{L_INDEX}</a><strong>&#8249;</strong> <a href="{navlinks.U_VIEW_FORUM}">{navlinks.FORUM_NAME}</a></li></b></font>';
}

In you HTML just add a div where you want to display the content.

<div id="myPlaceHolder"></div>

Be sure your script runs after the div tag otherwise document.getElementById("myPlaceHolder") returns null

Sign up to request clarification or add additional context in comments.

5 Comments

I have a problem now. It is using phpBB and the previous boards don't show in the link. It just shows the current board.
sorry mate I have no idea what is phpBB or the boards you are talking about. If you can give a more html related situation I can help.
Well if you look at the html you can see that it is getting some sort of data using those variable thingies. The boards are just forums. So right now it says: Board Index on index.php which is good. But when I got to a form connected to that it should say: Board Index < Forum Name. But it just says Forum name. I don't know where those variable things are stored though
i believe those are Smarty-code as Kjeld mentioned just try the google it check what variables do you have.
How do I run this in a html page?
0

Your code contains Smarty-code, which is kind of PHP. You propably can use

{if $smarty.server.REQUEST_URI == '/index.php'} 
    //Your HTML stuff here
{/if}

Edit: I should propably mention that the {stuff} is smarty-code. It is like php-code inside an html file. It is interpreted by php. That means, inserting it with javascript cannot possibly work, since PHP (and thus, Smarty) is interpreted on the server, while Javscript is executed on the client-side, that is, you home PC.

5 Comments

Do I just add this into the page as it is? The file is index.php
How do I run this in a html page?
Wait, so is the file you want to change index.php or something.html? You said both.
The page I am editing is html but I only want the link to display on index.php
Then yes, just try adding it. Even if it doesn't work, you won't break anything.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.