Log in

View Full Version : includes:



terriers33
10-03-2009, 07:21 PM
Please, please forgive me if i am posting a silly question that all you php people will think is so easy but i have tried and tried to get this sorted.

Sorry my name is Bill and i'm a photographer building a website to show images.

Have tried many gallery scripts and am going with this last one.

The problem i can't get my head around is this...
The install file states... edit the .php header or .php footer to add your own but when i open header.php...or footer in my editor its a blank page so i am stuck!!
I have an include navmenu.shtml file that i need to add but cant figure how to add it to this blank header.php???
Hope is running out lol

terriers33
10-03-2009, 09:38 PM
Suppose i am being very impatient but if nobody knows the way to go for me thats fine.....

traq
10-03-2009, 11:50 PM
Please post/link to your gallery script. No one can help if we can't see what you're doing...! :)

terriers33
10-04-2009, 12:32 AM
Hi,
The script is named picKLE
Got an idea how to handle most of it...

This is the relevant part from the install... file

__________________

INSTALLATION
__________________





(tested with apache 1.3.27 and php 4.3.2 - both win32 and unix/linux)
- Move the picKLE directory to a path accessable to the web
- Edit the picKLE-conf.php and make any changes
- chmod 777 picKLE-cache (win32 make sure webserver can write to picKLE-cache)
- Place directories of jpg, jpeg, gif, and png file in the picKLE-albums directory
- Edit header.php and footer.php in picKLE-includes if you want to add your sites header and footer

But when i open header or footer php there is no code.. blank page?

Jealy
10-04-2009, 12:43 AM
if you want to add your sites header and footer

They are blank so that you can add your own header/footer.

terriers33
10-04-2009, 01:05 AM
Thank you,
That part i understand but i am not a coder...
If it's blank and i have an include .shtml file how would i go about doing it?

traq
10-04-2009, 03:03 AM
header.php


<?php
include('/path/to/your/header.shtml');
?>

and the same for footer.php

If you have any further problems with this, please post a link to the picKLE script and show us the code you've written/modified so we can be of better help.

Sialkoti
10-04-2009, 05:41 AM
is that possible that can we include a html page in php page ? reply must

traq
10-04-2009, 06:00 AM
why don't you try it out? :)

terriers33
10-04-2009, 04:50 PM
Hi,
I have tried that already... please see images.

In the editor all that the header.php file contains is what i have put in it...
<? include('header.shtml') ?>

Saved it, uploaded it to replace the header.php in the includes folder, put the header.shtml into the includes folder?

I really am stuck on this, i am missing something simple but cant figure out what!
Thanks.

Master_script_maker
10-04-2009, 05:02 PM
try changing the code to <?php include('header.shtml'); ?>

traq
10-04-2009, 05:22 PM
yes, the long form always works better. You may also try an absolute path instead of a relative path:


<?php
include($_SERVER['DOCUMENT_ROOT'].'/absolute/path/to/header.shtml');
// OR, depending on your PHP version / options:
// include('http://www.yoursite.com/absolute/path/to/header.shtml');
?>

Master_script_maker
10-04-2009, 05:25 PM
Yes, but also there was a semicolon missing in his script.

terriers33
10-04-2009, 06:00 PM
Thanks for your help with all this,
In my way of thinking the part where i am going wrong is where to upload the header.shtml to.

If the header.php is in the includes folder where should i place the header.shtml file?

traq
10-04-2009, 08:55 PM
Yes, but also there was a semicolon missing in his script.
whoops - didn't catch that. :D

If the header.php is in the includes folder where should i place the header.shtml file?
Practically speaking, you can put it wherever you like. What you have to double-check is that your include() function correctly points to it.

If it's in the same folder as the include.php file, than just <?php include('header.shtml'); ?> is fine.

If it's in a subfolder, then you need to write <?php include('subfolder/header.shtml'); ?>.

In general, I prefer absolute or server-relative urls, like those I suggested above.

terriers33
10-04-2009, 09:20 PM
If it's in the same folder as the include.php file, than just <?php include('header.shtml'); ?> is fine.

That is what i have done but no luck
http://moe.enixns.com/~manchest/picKLE/index.php

This will not be my real address when this problem is sorted out

terriers33
10-04-2009, 10:33 PM
After many hours, and all your help i have found the answer to my issue.

The index.php code shows
include("./picKLE-includes/header.php");

I replaced it with
include("picKLE-includes/header.shtml");

But still one problem.... the header is there showing up but without the style sheet???
Sorry!

djr33
10-05-2009, 02:29 AM
Understand that PHP includes ONLY get the exact code inside the second page and place it into the first page. Any problems with stylesheets, layout, etc., are a problem with the html, not with the include. You must figure out what is wrong with the html, then how to fix it on the two pages.

The stylesheet probably isn't included in the main page's head section, since that's where it needs to be added as a tag.

Thus you have found one of the main problems using includes: placing one part in two places in the code.

The solution is to include two parts, or just hard-code the stylesheet into the top. Alternatively you could set up a complex system where you have an include with two parts as variables, then output one in the head section and one in the body; but that is complex and more work than just doing it separately. Basically, that's moving on toward a template setup, which would be useful if you were doing more than just a simple include.

traq
10-05-2009, 03:25 AM
...Alternatively you could set up a complex system where you have an include with two parts as variables, then output one in the head section and one in the body; but that is complex and more work than just doing it separately. Basically, that's moving on toward a template setup, which would be useful if you were doing more than just a simple include.

That's what I'm doing now... like you said, it's complicated, but very rewarding when it finally works like it should. (SO cool to get html that validates...!) And, fortunately, I only ever have to do it once.

terriers33
10-06-2009, 02:52 PM
I am not quite sure its a stylsheet issue...thats what i did think.
Could it be the header images???

If you could check these two images
One is my header that works fine on the other shtml pages, abut us etc.

The other is how the header shows up on the picKLE index.php page.

Thanks.

terriers33
10-08-2009, 05:54 PM
The stylesheet probably isn't included in the main page's head section, since that's where it needs to be added as a tag.

This is the head section from (index.php from picKLE)

<HTML>
<HEAD>
<TITLE>
<?php echo '' .$gallery_title. ' - ' .$title. ' ' .$version. '';?>
</TITLE>
<link href="style.css" rel="stylesheet" type="text/css">
<?php
if ($slide == '1') {
$gallery->picKLEslide();
}
?>
</HEAD>

As you can see it has style.css but that is for picKLE.

How can i add the additional style.css that makes the header show correctly, you say hard-code, template, i am not experienced enough to understand your comments let alone to carry them out!

You replied with...
or just hard-code the stylesheet into the top


Please if you can help i would appreciate it

traq
10-08-2009, 06:38 PM
place your stylesheet link just below the link to the picKLE stylesheet. Make sure the href (path) is correct; if your stylesheet is also called style.css (boring!) you'll need to either rename it or place it in a different folder.

<HTML>
<HEAD>
<TITLE>
<?php echo '' .$gallery_title. ' - ' .$title. ' ' .$version. '';?>
</TITLE>
<link href="style.css" rel="stylesheet" type="text/css">
<link href="/path/to/your/stylesheet.css" rel="stylesheet" type="text/css">
<?php
if ($slide == '1') {
$gallery->picKLEslide();
}
?>
</HEAD>

terriers33
10-21-2009, 05:45 PM
Hi again,
I think i am almost there regarding the header and stylsheet issues (with your help that is)

Just this one thing i can't figure.

The header is working so is the css apart from the size of the text being much smaller on the picKLE page than it is on the shtml pages...baffled.

Two images to show what i mean.
Thanks again to everyone.
Maggs.

traq
10-21-2009, 07:46 PM
what is your css sheet like; specifically the part that deals with font size...? if you're using ems, %'s or a relative keyword (e.g., smaller), it may be cascading with some other text-size setting.

Have you tried simply making your font-size larger? might not be the cleanest way, but it would still work.

terriers33
10-22-2009, 07:24 PM
Thanks Traq,
I apologise, i was working on the wrong stylesheet!!
Changing the font size as you suggested has worked great.

As i said at the beginning of my posts i am not a coder, especially with php, i am always wary of deleting parts of the script i dont want or need in case i mess up the whole thing.

By talking to you guys i have been learning and experimenting, have made mistakes along the way.

The php coding still confuses me, the main part being how to exclude parts not required.

I need, or would like to remove all the text apart from the title of the image from the page...picture attached.
Thanks,
Maggs.

traq
10-22-2009, 08:14 PM
Well, if you're uncomfortable deleting parts of scripts (and you should be), just

/* comment them out */

and you can see if you like it that way without actually screwing anything up beyond repair. Similarly, you can

//make a commented note

about pieces of code you add, so you can edit them out again if they don't work properly.

//end of note

terriers33
10-22-2009, 08:52 PM
That must make sense to you...but not me!
How,where, and what wording would i place:

/* comment them out */

Sorry for bothering you with all this.
Maggs.

traq
10-23-2009, 12:52 AM
this: /* starts a comment,
and this: */ ends a comment in php. all code between the /* and */ symbols is ignored, as if it were deleted, but if I need to restore it all I need to do is remove the comment tags.

A one line comment uses two slashes, // like this. After a
line break, the comment ends (there is no closing tag).

When adding code to a modify script, I usually use comments to remind myself which code is mine
/* OLD CODE commented out
if(it_works){
echo 'Don\'t fix it';
}
END old code */
// MY CODE FOLLOWS
if(new_function_works){
echo 'It works';
}else{
echo 'Delete this, it sucks.';
}
// END my code



...I need, or would like to remove all the text apart from the title of the image from the page
^ Sorry, I just caught that part of your post.

I wouldn't be able to give you any specific help with that without seeing the actual script, so I could find the relevant lines of code.

terriers33
10-23-2009, 01:57 PM
Hi,
I think i could manage to do that if only i knew where to put the comments.

I have attached the index.php file as a zip (hope it works)
Thanka again,
Maggs

terriers33
10-25-2009, 08:37 PM
Thanks anyway,
Sorry for being presuptious.
Maggs.

traq
10-25-2009, 11:40 PM
sorry... I lost the thread.

line 438 looks like this:

echo '' .$display2. '<center>Resampled size:<font color="gray">' .$size_new. '</font>Original size:</center><font color="gray">' .$size_orig. '</font><center>';

comment it out:

/* echo '' .$display2. '<center>Resampled size:<font color="gray">' .$size_new. '</font>Original size:</center><font color="gray">' .$size_orig. '</font><center>'; */

and see if that does it

terriers33
10-26-2009, 12:04 AM
Thanks for that,
My question was how to remove all the text, ie, size, date uploaded etc and just leave the name of the image.

traq
10-26-2009, 12:17 AM
$display2 is the "File uploaded on..." line. $size_new and $size_orig appear to be the "Resampled size..." and "Original size..." lines.

I didn't install picKLE to test my suggestion above, but commenting out the line that echos those variables (line 438) should work. If it doesn't, or if there are unintended side effects, remove the comment tags and we can try something else. Did you try it?

terriers33
10-26-2009, 06:33 PM
Please forgive me for not quite understanding you at first.
I have tried the commenting out as you suggested, works like a dream!!

http://moe.enixns.com/~manchest/picKLE/index.php?album=nights%2F&pic=2.jpg

I was about to give up on this script, too many changes to be made with me not knowing how but it is shaping up with your help, i tried contacting the guy who wrote it but the email is no longer in use.

If i could ask a couple of more things?
I tried to comment out the rest of the text below the image...
indexed by..
content by...

All i want there is copyright manchesterpics.com © 2009

When creating/adding albums they all have a folder.png as the thumbnail, i changed that to one of my images... using the same title but now all the albums have the same image as a thumb cant figure how to add seperate image thumb for each album.

Finally, when trying to change background colour using config.php nothing happens!
Thank you for all your help.
Maggs.

traq
10-26-2009, 09:03 PM
I'll look through it for you. basically, look through the script for the words/phrases you want to get rid of.

If the line is something like $whatever = 'Words you don\'t want to show'; then don't comment it out - the variable ( $whatever ) might be needed somewhere else, so removing it would cause an error.

Instead, look for a subsequent line that looks something like echo '<p>'.$whatever.' and maybe other stuff</p>'; -that's the command to write it to the page, and commenting it out shouldn't have any serious consequences (maybe some css or layout problems).

terriers33
10-27-2009, 07:10 PM
Wow!
I have managed to do something on my own lol.

Managed to remove the unsightly indexed by and content by wording from the script and replace with one line copyright manchesterpics.com

Still stuff to do but i am using this as a learning experience.
Maggs.

traq
10-27-2009, 07:56 PM
cool, congrats

terriers33
10-27-2009, 09:48 PM
thanks so much.

terriers33
10-28-2009, 05:22 PM
There are just the two problems left....

How to have a different thumb image for each album created by picKLE...
How to change the background colour of picKLE
(have tried changing in config.php but nothing happens)

Oh and would i need to put my own meta tags in index.php for SEO
Thanks,
Maggs