View Full Version : Need help in trying to include a php file in tabbed menu

04-22-2007, 11:36 PM
1) Script Title: Ajax Tabs Content script

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/ajaxtabscontent/index.htm

3) Describe problem:

I'm using the DD Ajax Tabs Content script on the front page of my Forum (http://www.mykimbrell.com/FamilyForum/index.php) and it works great.
My issue is that the content I want to add is just not working no matter how the code is written. (so far) :)
My current set up is with:
SMF 1.1.2
TinyPortal v0.9.8
Coppermine 1.4.10
cpmfetch 2.0.0

It’s all working OK and so there are no issues there, but the php file I want to call into the display in the Welcome tab of the DD menu is where I need help.

So here it is;
I’m trying to include the output of my cpmfetch ‘randonpic.php’ file at the bottom of the Welcome tab inserting it below the content that’s already in place there.
the 'cpmfetch' utility is setup to pull random selections from the Coppermine gallery and display them as seen at this next link, the pics change each time the page is refreshed

This is the code that is in the randompic.php file:

print "<center>";
include "./cpmfetch.php";
$objCpm = new cpm("./cpmfetch_config.php");
$objCpm->cpm_viewRandomMedia(1,3,array("imagesize" => "Thumb","imageheight" => "75","imagewidth" => "100","windowtarget" => "_new","alttag" =>"From Album: %a Added: %w"));
print "</center>";

I’ve searched the here in the DD pages, the cpmfetch pages and did Google searches but so far I'm just not finding the fix.

This is one of the versions of code that has been tried for pulling the cpmfetch output into the welcome tab…

<?php include("/cpg1410/cpmfetch/randompic.php"); ?>
This one and others have been tried in various spots in the existing code and with and without various tags,
You can see the current attempt at the bottom of the code below.

I would be most thankful for any help.

Here is the code from the DD tabbed content script:

<style type="text/css">
padding: 3px 0;
margin-left: 0;
margin-bottom: 0;
margin-top: 0.1em;
font: bold 12px Verdana;

#tablist li{
list-style: none;
display: inline;
margin: 0;

#tablist li a{
padding: 3px 0.5em;
margin-left: 3px;
border: 1px solid #778;
border-bottom: none;
background: white;

#tablist li a:link, #tablist li a:visited{

#tablist li a.current{
background: none;

width: 450px;
/* Insert Optional Height definition here to give all the content a unified height */
padding: 5px;
border: 1px solid black;



<script type="text/javascript">

* Tab Content script- ? Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code

//Set tab to intially be selected when page loads:
//[which tab (1=first tab), ID of tab content to display]:
var initialtab=[1, "sc1"]

////////Stop editting////////////////

function cascadedstyle(el, cssproperty, csspropertyNS){
if (el.currentStyle)
return el.currentStyle[cssproperty]
else if (window.getComputedStyle){
var elstyle=window.getComputedStyle(el, "")
return elstyle.getPropertyValue(csspropertyNS)

var previoustab=""

function expandcontent(cid, aobject){
if (document.getElementById){
if (previoustab!="")
if (aobject.blur)
return false
return true

function highlighttab(aobject){
if (typeof tabobjlinks=="undefined")
for (i=0; i<tabobjlinks.length; i++)
var themecolor=aobject.getAttribute("theme")? aobject.getAttribute("theme") : initTabpostcolor

function collecttablinks(){
var tabobj=document.getElementById("tablist")

function detectSourceindex(aobject){
for (i=0; i<tabobjlinks.length; i++){
if (aobject==tabobjlinks[i]){
tabsourceindex=i //source index of tab bar relative to other tabs

function do_onload(){
var cookiename=(typeof persisttype!="undefined" && persisttype=="sitewide")? "tabcontent" : window.location.pathname
var cookiecheck=window.get_cookie && get_cookie(cookiename).indexOf("|")!=-1
initTabcolor=cascadedstyle(tabobjlinks[1], "backgroundColor", "background-color")
initTabpostcolor=cascadedstyle(tabobjlinks[0], "backgroundColor", "background-color")
if (typeof enablepersistence!="undefined" && enablepersistence && cookiecheck){
var cookieparse=get_cookie(cookiename).split("|")
var whichtab=cookieparse[0]
var tabcontentid=cookieparse[1]
expandcontent(tabcontentid, tabobjlinks[whichtab])
expandcontent(initialtab[1], tabobjlinks[initialtab[0]-1])

if (window.addEventListener)
window.addEventListener("load", do_onload, false)
else if (window.attachEvent)
window.attachEvent("onload", do_onload)
else if (document.getElementById)


<ul id="tablist">
<li><a href="" class="current" onClick="return expandcontent('sc1', this)">Welcome!</a></li>
<li><a href="" onClick="return expandcontent('sc2', this)" theme="">Faces, Places & Events</a></li>
<li><a href="hot.htm" onClick="return expandcontent('sc3', this)" theme="">Links</a></li>
<li><a href="search.htm" onClick="return expandcontent('sc4', this)" theme="">Search</a></li>

<DIV id="tabcontentcontainer">

<div id="sc1" class="tabcontent">

<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
.style4 {
text-align: center;
.style3 {
font-size: xx-small;
//color: #000000;

<table border="1" width="72%" id="table2" style="border-collapse: collapse">
<td align="center">
<h3 class="style4">Welcome to Your Fam<b><em><span class="style3"></span></em></b>ilyForum
& Web Site!<font size="1"><br>
We invite you to browse the pages of the FamilyForum and we would love to
have you join in with us and become a member so that you can keep all the
family up to date on what's happening where you are.<br>
Take a look at <a href="http://www.mykimbrell.com/FamilyForum/index.php?topic=31.msg52">
<font color="#87CEFA"><b><u>Who Can Become A Member</u></b></font></a> to
read up on how to become a member of Your FamilyForum.</font><font size="2"><br><br>
<font size="1">You can <a href="http://www.mykimbrell.com/FamilyForum/index.php?action=register"><b><u><font color="#87CEFA">Go Here</font></u></b></a> to Join (register) for Your FamilyForum.</font><br>
</font><b><i><font size="2">Enjoy... G-Pa Ken & G-Ma Kay<br>
<strong><font size=3><br>
<p align="left"></p>



<?php include("/cpg1410/cpmfetch/randompic.php"); ?>


<br />

04-23-2007, 07:53 PM
Lets take a step back and disregard the Ajax Tabs content script completely. How would you include the contents of http://www.mykimbrell.com/cpg1410/cpmfetch/randompic.php on your forum pages, period? Does the code:

<?php include("/cpg1410/cpmfetch/randompic.php"); ?>

work to show the images? Different forum systems support different ways of embedding PHP code inline within their templates, hence I ask this. Once you've figured that out, the first tab of Ajax Tabs Content (ie: the "Welcome Tab") simply displays whatever HTML you put inside the Content DIV. In other words, the first tab doesn't use Ajax to fetch its content, so assuming you've figured out the first part of my question, the solution may just look like this:

<div id="ajaxcontentarea" class="contentstyle">
<p>This is some default tab content, embedded directly inside this space and not via Ajax. It can be shown when no tabs are automatically selected, or associated with a certain tab, in this case, the first tab.</p>
<?php include("/cpg1410/cpmfetch/randompic.php"); ?>

04-24-2007, 02:13 PM
Thanks for the reply ddadmin,
Sorry but that one didn't work out.:)

After doing lots of reading on several different sites/forums it sounds like one very possible answer is that my server may not be set to allow what is being tried here so I have a posted the question to my host to see if thats it.

Thanks... Ken

04-24-2007, 06:58 PM
You most likely will want to look at the docs of SMF (your forum software) instead on how to include a PHP file on your forum pages. That's the key to getting this to work based on what you have right now.

04-25-2007, 12:08 PM
Well we've achieved a participial solution! :)

My host informed me that for this too work the page where it is to be displayed should have the extension .shtml, so...

Changing the page extension works for doing the output display to a regular page, but when trying to use that same code to pull the cpmfetch output into the Ajax menu as outlined in my first post it fails.

What I've tried to do is make a page called dd_menu.shtml and then insert the code for the cpmfetch call in that shtml page... when the menu page is called into a browser it looks as expected but depending on what code is tried for the insertion it will either not show the target content (photos) or throw an error.
You can see the Ajax page at this link:

Code currently in place giving a blank return:

<?php include("http://mykimbrell.com/cpg1410/cpmfetch/randompic.php\"); ?>
Another try:

<!--#include virtual="http://www.mykimbrell.com/cpg1410/cpmfetch/randompic.php" -->
A lot of different variations of the two code samples posted here have been tried.

All the while I have thought that this issue was simply a matter of the correct code string for making the call and I still think so but for now I'm stumped as to where to look for an answer.
It's not the most important thing in the world of course, but it sure would be nice to solve this riddle. :cool:

Thanks... Ken