News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

adding a <div> to home page

Started by VE3JOC, April 16, 2020, 11:52:51 AM

Previous topic - Next topic

VE3JOC

I want to add a <div> just below the header on my home page in SMF 2.0.17.  Where would I find the source file to add the <div>?

Thanks
http:\\visualfoxproforums.com - Dedicated to Foxpro Users Everywhere.

Kindred



index.template.php

However, adding it just below the header means, unless you add conditionals, it will be added to EVERY page, not just the home page.



So.... rather than assuming you have to do XYZ, why don't you tell us specifically what you are trying to accomplish and we might be able to help you better.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

VE3JOC

What I want to do is to display a paragraph of text stating what the purpose of the site is.
http:\\visualfoxproforums.com - Dedicated to Foxpro Users Everywhere.

Kindred

you could use the NEWS section for that.... or install an ad management mod (which would allow you to add a block of text where you indicated)
-- or a full portal mod, which would allow for blocks to be added in many different places with many different conditionals...

but, if you insist on hard coding it...   you would want to put it into index.template.php, with conditionals to determine if it is the homepage or some other page...

or in boardindex.template.php, which would place it lower than you indicated, but would be limited to only the homepage.

Personally, I'd suggest either the news or ad management mod...
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

VE3JOC

I didn't want a portal.  I'll see if I can find an ad management mod.  Thanks for the help.  Much appreciated.
http:\\visualfoxproforums.com - Dedicated to Foxpro Users Everywhere.

drewactual

i highly recommend using conditional for this- it can be leveraged for all kinds of things... and use it with an 'include' to your index.template so as not to make a mess of things.  i use this method a lot, and it really works out nicely for my purposes.

drewactual

this is going to seem complicated if you're a novice.  it's pretty simple, don't be intimidated.  what this will provide you with is a way to interject or to eliminate custom coding depending on what a user is asking of your site (whether they are looking at the index, posting, looking at a board you want presented different than another board, ect- it is conditional to the action/page the user is on).

what i'm going to hang here as attachment to this post is a file you can add to the base directory of your forum.

the instructions are explicit and easy to follow in the file, and are so simple i simply used php comment function to explain them.

what this will do is allow you to add html/php code to ONLY specific pages be that a board, topic/thread/message, or action.  OR, you can leave them blank and not show a thing in those locations. to achieve that, you'll want to remove the brackets and the placeholder text and have nothing in it's place.

the only alteration to your index.template is a php include (don't use require).  you plant that precisely where you want the function to present.  I use multiples of these in various places which are all pretty much the same principle.

in the index.template.php file, as a for instance, and right after the closing of the header, you CAN place an include there and use CSS to hide it such as :

.hidden-header{display:none} /*if added to your main css file*/
or
<div style="display:none"> /*if added directly into the code you're injecting*/

and place in it an H1 with specific language about the page in question, and even differentiate between that page and another page on your site- such as another board... you'd simply use the file provided below and change the name to something, perhaps like "index-custom-include-for-h1.php", and then include it (as mentioned just after the closing of header) and alter your index.template file to:

</head>
include('path-to-your-file/index-custom-include-for-h1.php');


you can use them for custom headers for the index of your forum, a specific board or all boards, a topic page, or actions.  it's all about where you plant the php include in your index.template as to where it can be used.  it can also be used on board templates... but let's keep it simple for now.

you MAY be required to use absolute paths instead of relative depending on how your server is set up... i'd recommend you DO use absolute as opposed to relative, as it's safer.

in the attached file, each call has an echo... the information to echo is within the brackets.  when you add your own code make sure to remove the placeholders i put in the brackets AS WELL AS THE BRACKETS THEMSELVES.

I also exhausted most of the 'actions', which you may or may not want to do.  it's up to you and depending on what you are using this for.

you can check out my site to see how this works if you want- it is hxxps://www.cfb51.com ... i use it to exchange H1's on every board, to interject a differing top stripe (look at the conference boards) and to either allow or disallow the big rotating top banner.  I also use it to use different badges (top right column) for each board.  I use it for a lot of things, actually, and it serves me very well.

caveat: IF what you seek is simple, you can simply copy that if/elseif/else statement from the file and place that code directly in your index.template file, in the location required to achieve your goal.  the issue with that is this works, basically, through the process of elimination so if you want it on your index page you have to eliminate all the others and keep it JUST on your index page.  for that reason it is better to keep the clutter (wall of if/elseif/else statements) out of your index.template and simply use the php include to include it.

i recommend 'include' over 'require' because an include- if it fails for whatever reason- will NOT break your page... a 'require' will.  I've been using this for years and have had zero issues.  I hope it serves you well, too.

VE3JOC

After reading the reply by Kindred, I installed the ad_management mod but I couldn't seem to get it to work so I just hard coded it into the index.template.php file.
It may be a bit of a kludge but it seems to work.

You can see what I mean if you go to  vfpforums.com

Thanks to all for their suggestions.  Very much appreciated!
http:\\visualfoxproforums.com - Dedicated to Foxpro Users Everywhere.

VE3JOC

Thanks drewactual. I have downloaded your attachment and I'll take a stab at it.

I looked at your web site and its really nice.  Do you use a mod to get that image and scroll over?

Thank you very much.
http:\\visualfoxproforums.com - Dedicated to Foxpro Users Everywhere.

drewactual

Nope, it's hard coded.  It's a part of one of these conditional includes... changes between 180 or so images on each reload.

VE3JOC

Guess I'm just too slow or something.  I can't seem to get that index-custom-include.php working for me.  I put the index-custom-include.php file in the root of the site and the include statement into the index.template.php.  In this experiment I have a copy smf installed on a test server so that I don't screw up my live site. If I can get this going on the test site I'll transfer the files over to the live site.

I have attached the 2 files if you can look and see what I'm doing wrong.  I commented out my hard coding in the index.template.php.


http:\\visualfoxproforums.com - Dedicated to Foxpro Users Everywhere.

drewactual

change what you have (with the http) to:

include('/smf/index-custom-include.php');


that, however, is a relative path... it's even a short cut relative path... you'd be better served using the absolute... are you using cpanel?  if you are in the upper left corner of the editing page you'll see the absolute path to the file you're editing (with everything but the file you're editing's name) .... it will look something like: "/home/yourdomain/public_html/smf"

VE3JOC

Thanks drewactual,  I got it working now.  The only problem is that, since I only wanted it on the index page, I deleted all of the IF...Elseif  and Else statements and left only the one that says "the final one which will appear on your index through process of elimination AND all other pages NOT mentioned above". but it is still appearing on all forums and posts.  Sorry to be a bug but it is working well except for that.

http:\\visualfoxproforums.com - Dedicated to Foxpro Users Everywhere.

drewactual

In order to have it ONLY on the index page, all those other pages have to have the script inject NOTHING on their respective pages.  You have to use the process of elimination, leaving only the ones NOT addressed in the other elseif statements to have that script.

Get a fresh copy of the file I provided... delete everything between echo'  and the '; and leaving the echo' and ';  on each elseif... then on the last, the "else", place your html or php where the brackets and placeholder text is...

You're almost there....

drewactual

I'm on a phone.. give me a bit and I'll draft it for you and hang it up here.

drewactual

i took some liberties with your html, and placed them in a div... i used p's as well to split it up properly. 

if you'd like, you can leave the style i provided intact JUST as it is in the attached file, OR, you can add this to the bottom of your style.css file IN THE THEME you're using's directory...


.include-or-not {display:block;width:99%;margin:auto;padding:.5em;border:1px solid blue;border-radius:.5em;}


the file should work as you want (thought you may want to play with the styling i provided) as is- simply upload it to the same place you have the other one, effectively overwriting it.  when you save it to your computer lose the (1) part of the filename.

i'll hang around a bit for questions or issues.

VE3JOC

PERFECT!   Thanks drewactual.  Everything is perfect.  I just changed the div border color, centered the text and changed the font color as well as bolding it.
Thank you very much for your great help and your patience with me.

Stay safe and stay healthy!
http:\\visualfoxproforums.com - Dedicated to Foxpro Users Everywhere.

drewactual

good to go!  i like it when it comes together!!! you stay safe (and six feet away) as well!

Advertisement: