News:

Wondering if this will always be free?  See why free is better.

Main Menu

php include in index.template.php ?

Started by khanahmedabbas, January 13, 2013, 10:39:42 AM

Previous topic - Next topic

khanahmedabbas

Hi,

Is it possible to add any kind of html in index.template.php theme using php include ? if yes what code we must add ?

Because i tried to add html code into index.template.php and it showed ' ; string errors.

Please reply in detail as i have the latest version of SMF here http://www.gyaro.com/forum/ [nofollow]

Arantor

It would be useful to know exactly what you're trying to include and where you're trying to include it, especially as direct inclusion into index.template.php is usually a really bad idea.
Holder of controversial views, all of which my own.


khanahmedabbas

i am trying to php include header page of www.gyaro.com [nofollow] into forum theme.

Arantor

I actually meant specifics... are you trying to just include a PHP file or trying to include some content directly?
Holder of controversial views, all of which my own.


khanahmedabbas

i am trying to include php file which has content.

Quote<?php
include("http://www.gyaro.com/forum/forumheader.php [nofollow]"); ?>

khanahmedabbas

i want to include this page http://www.gyaro.com/forum/forumheader.php [nofollow] content either using php include or html code but unable.

Any clues ?

Arantor

And, as already asked, where exactly are you trying to put that?

Also, you should never, ever, ever, ever try to use include() with a URL, apart from the fact it won't work, it is also a security risk. What is forumheader.php exactly?
Holder of controversial views, all of which my own.


khanahmedabbas

i am trying to put this <?php
include("http://www.gyaro.com/forum/forumheader.php [nofollow]"); ?>

After the body tag in index.template.php in current theme of gyaro forum www.gyaro.com/forum/ [nofollow]

like this

Quote<body>';

<?php
include("http://www.gyaro.com/forum/forumheader.php [nofollow]"); ?>
}

function template_body_above()
{

but getting errors.

This file http://www.gyaro.com/forum/forumheader.php [nofollow] is basically html page which i changed into php.

But when i add into index.template.php it shows string errors.

Arantor

Which part of NEVER USE INCLUDE ON A URL is causing you problems here?
Holder of controversial views, all of which my own.


khanahmedabbas

I really didn't understand what you meant to say Arantor.

I also want to add this page http://www.gyaro.com/forum/forumfooter.php [nofollow] in the footer.

Arantor, if you give me solution i would not mind giving you 1 gyaro license copy as complimentary free of cost.

Thanks.

khanahmedabbas


Arantor

I give up trying to help. If you don't understand the difference between a local file and a URL, not only do I not want to spend an age trying to explain, but I wouldn't want to use your software either...
Holder of controversial views, all of which my own.


khanahmedabbas

what shall i do my friend ? dont give up as it will make you fail.

mashby

include_once('forumfooter.php');
That is likely what you need for the footer and a similar one for the header. Give the attached a try.
Always be a little kinder than necessary.
- James M. Barrie

khanahmedabbas

Thanks it worked but header is having conflict with SMF forum css.

NanoSector

Well that's not something we can do something about. I recommend changing your code and not the code in SMF, as changing SMF's code might break more things.
My Mods / Mod Builder - A tool to easily create mods / Blog
"I've heard from a reliable source that the Answer is 42. But, still no word on what the question is."

mashby

At a minimum, your header/footer are their own complete HTML pages. Consider removing <head> and putting the CSS callouts in index.template.php (or include the guts of it into the one on the theme you are using. Also, you now have three body declarations. Considering these are includes, only include the bits that need to be there. index.template.php provides the complete page skeleton. The header is being declared right after <body>, so only include the code bits that appear after your current forumheader.php file in it and move the CSS stuff to index.template.php. Rinse and repeat for the footer include file.
Always be a little kinder than necessary.
- James M. Barrie

lomaalta

I must be missing something simple - or a lot of brain cells (possible) - my eyesight also sucks, so maybe this crippled old man just needs a little help. ;)

Inside index.template.php

and outside any function or echo, just below the body tag ;)   I have.....

include_once('/myfile.php');

In myfile.php I have tried

<?php

echo 'my text';

?>

-------------------

echo 'my text';

------------------

and....

my text

Nothing is working -

What am I doing wrong?

Arantor

Because the path you've specified is probably wrong.

/myfile.php points to the top-most level folder on the system, and I'd be extremely surprised if that was the real path.

In all likelihood the correct path is more like /home/username/public_html/myfile.php but it's impossible to know without more information.
Holder of controversial views, all of which my own.


lomaalta

Well, you are right, that was not the actual path...

My site resides here..

http://www.mysite.com/

My path to the file...

ftp://mysite.com//domains/mysite.com/public_html/includes/my.php

pull it up in safari just fine at...

http://www.mysite.com/includes/my.php

But this does not work...

include_once('/includes/my.php');

Advertisement: