I am trying to include a header which i made separately into my index page. When I try to include and run it, it does not display the header that I made although the paths are all correct. please help me on this. thanks. I am a newbie in php, css and html.
Here is the link for pictures and codes: http://www.fileden.com/files/2011/7/27/3174077/My_Documents/Folder.rar
include code:
</head>
<body>
<div id="main_container">
<div>
<?php
include 'include/header2.php';
?>
</div>
<div class="main_content">
<div class="menu">
<ul>
<li><a class="current" href="../../index.php">Home</a></li>
<li>Job Orders<!--[if IE 7]><!--><!--<![endif]-->
<!--[if lte IE 6]><table><tr><td><![endif]-->
<ul>
so on and so forth...
I can only guess, but I think 'include/header2.php' is pointing at something other than what you intend it to. Take a look at the docs on include path. You can check your current include_path with phpinfo and work from there.
Yeah, turn on error reporting and see what php is telling you. You can also try to give an absolute path for your include, like:
include('/var/web/include/header2.php');
It's not really advisable to use absolute paths like this, but it might help you find out what exactly is going wrong.
Related
I've been trying to get information from WP for a while now and I still can't get it to work. What I'm trying to do is to get the information from an online resume and display it on the site.
The problem is that I haven't worked with WP a lot before and I can't figure out if there is a better way than SQL extraction to get that information.
This is the code I have now, it's very simple but doesn't work.
$output = '
<html>
<head>
<link rel="stylesheet" type="text/css" href="style1.css">
</head>
<body>
<div id="header">
<h1 class="title">'.the_custom_field('_candidate_name', 144).'</h1>
<ul class="contactInformation">
<li id="fullName">//This is where the name should go</li>
<li id="adress">//I want to fetch the adress and echo it here etc.</li>
<li id="phoneNumber"></li>
</ul>
<div id="resumePicture">
<img src="mVqghXM.jpg" height="auto" width="100px">
</div>
</div>
<div id="education">
<ul>
</ul>
</div>
<div id="experience">
</div>
</body>
</html>';
I've tried using get_custom_field as well as get_resume_field and placing them into a variable but i get an error that says it's undefined, and I presume that is because I don't have the WP Job Manager Field Editor plugin.
I would rather find another way to do this, either via some other WP compatible function or via SQL, instead of having to buy that plugin.
I would also love one of you to explain to me briefly how the WP system/database is built, because that would help immensely.
Thank you!
EDIT: I found the way of fetching the data from the database. It was get_resume_field, but what I'd done was copy the meta_key straight off the database, being "_candidate_name", but when I took the first underscore away, it worked. Thank you both for helping with the two problems I had. Cheers!
Use three files in your custom php file to get and use all wordpress function. Try this.
include_once("/path/to/wordpress/wp-config.php");
include_once("/path/to/wordpress/wp-load.php");
include_once("/path/to/wordpress/wp-includes/wp-db.php");
You have made to collect all the HTML into a single variable as per you need.
The major important thing is that you have to echo/ return the variable to print the output.
This will do the trick if you return it from a function
function get_page()
{
$output = '<p>Welcome</p>';
$output .= '<p>Again</p>';
return $output;
}
After the return you have to echo the statement by calling the function
$test = get_page();
echo $test;
Output:
Welcome
Again
I added some php to some of my pages, but its not coming up on any of the pages.
<body class="menu">
<!-- Slide bar starts here -->
<?php require ('/Php/Slider.php');?>
<!--Slide Bar Ends Here-->
<div class="body">
Store Comming Soon
</div>
<script src="store.js"></script>
</body>
in the php file I had this.
<header>
<a href="#" class="menu-toggle">
<div class="bar"></div>
<div class="bar"></div>
<div class="bar"></div>
</a>
<nav class="menu-side">
<div class="listing">
<div class="box"><a class="list" href="/"><h1>Home</h1></a></div>
<div class="box"><a class="list" href="/DayZ_Home/"><h1>DayZ</h1></a></div>
<div class="box"><a class="list" href="/Photos/"><h1>Photos</h1></a></div>
<div class="box"><a class="list" href="/Store/"><h1>Store</h1></a></div>
</div>
</nav>
</header>
This is the exact same for all my pages, and nothing is coming up.
This is the error I get:
[02-Oct-2015 22:44:59 America/Denver] PHP Warning: include(): Failed
opening '/Php/Slider.php' for inclusion
(include_path='.:/usr/php/54/usr/lib64:/usr/php/54/usr/share/pear') in
/home2/itskeega/public_html/index.php on line 14
Any Idea what is wrong?
Simply try this first : Remove slash in front of php in the path and run again.
If that don't work continue reading.
Let me help you as much as I can.
First thing first, this
[02-Oct-2015 22:44:59 America/Denver] PHP Warning: include(): Failed
opening'/Php/Slider.php' for inclusion
(include_path='.:/usr/php/54/usr/lib64:/usr/php/54/usr/share/pear') in
/home2/itskeega/public_html/index.php on line 14
(just stating the obvious to me) This means,
There is a FIle called 'index.php' in public_html directory
It has a function "include()" on line 14 in its code.
The include function have a path in parenthesis following it.
There is a error in that path.
Either file "Slider.php" is not there or the script can't read it.
how do i know it for sure ?
Failed opening'/Php/Slider.php' for inclusion
Why did I tell this ?
It will help to understand errors next time.
Now let's try to solve the error, what I would do first to confirm the file permissions and every other thing is
Move the file to "public_html" folder itself.
new Path will be just Slider.php (Take note of the case).
Run your script and look for errors now.
That is the simplest way to do it.
Be very very precise in the "case" becuase I see you are not using the php conventions of naming everything.
Report back with the directory structure so we can help further.
'/Php/Slider.php' I assume you have Slider.php inside Php directory, Now the correct way to include would be:
require ('../Php/Slider.php');
Which will go back first, open the Php directory folder and look for Slider.php file.
<body class="menu">
<!-- Slide bar starts here -->
<?php require ('../Php/Slider.php');?>
<!--Slide Bar Ends Here-->
<div class="body">
Store Comming Soon
</div>
<script src="store.js"></script>
</body>
EDIT:
Moving forward from the comments under this answer, you stated your directory structure as:
/public_html/index.php (home page)
/public_html/Php/Slider.php
Which means the approach I stated was fine.
To go from index.php to Slider.php the way would be:
../ (Go back)
Php/ (Open the Php directory)
Slider.php (Look for Slider.php)
Hence, require ('../Php/Slider.php');
As you mentioned that you are including this file in whole project , yet you did not mention the dirctory structure . It is always better to include files with absolute path .
try as below -
<body class="menu">
<!-- Slide bar starts here -->
<?php
$file=$_SERVER['DOCUMENT_ROOT']."<--your project dir-->".'/Php/Slider.php';
require ($file);
?>
<!--Slide Bar Ends Here-->
<div class="body">
Store Comming Soon
</div>
<script src="store.js"></script>
</body>
<?php require ($_SERVER["DOCUMENT_ROOT"]."/path/to/file.php");?>
$_SERVER["DOCUMENT_ROOT"]. Makes your path start at /public_html/
I've been looking at this for a few hours now and I've probably overlooked something silly, but I really can't get this to work.
I have created a .php file with four different php-files which are included with the
I am practicing with building websites and my first website used to solve this problem with frames, I could simply target every anchor tag to the mainframe and it worked perfectly. However, as frames are a deprecated feature, I decided to replace them. I can't seem to get the links working however.
There are tons of answers around, and that's probably the biggest problem, I can't figure out which solution fits to my specific design. Sorry if this is a doublepost.
This is what I've created so far:
<div id="header" class="header">
<img src="Images/metallic.png" width="125" height="125" alt=""/>
<img src="Images/database.png" width="85%" height="125" align="right" alt=""/>
</div>
<?php include 'Parts/upperdivs.php'; ?>
<?php include 'Parts/navigation.php'; ?>
<?php include 'Pages/main.php'; ?>
As said, there are buttons with hyperlinks in the navigation page and 'normal' hyperlinks in the upperdivs. Is there a way to open all those hyperlinks in the main content div, without having to copy all I've already got? I've read a lot of information about Ajax and the PHP-load feature, but I'm not sure what I should use. I've tried adding it as well, but couldn't get it to work. Thanks in advance!
Edit: I've also tried using an Iframe with an Iframe ID, and pointing to it using the target-tag. The problem is that the pages differ very much in content - if I set the height of the Iframe to, let's say, 1000px, it's way to large and you can scroll too far down on pages with minimal content, and if I set it to 100px, I get two scrollbars, one on the Iframe and one on the right side of the webpage, which is very ugly - and above all - very annoying.
Without being clear on exactly what you're asking, I assume you're looking for an easier way to handle includes.
This is not the best way to do it, but I would have each page be in the URL you want, and have the 'Parts' pages be in a separate folder.
/
| main.php
| about.php
| news.php
/ Parts
| navigation.php
| upperdivs.php
| EVERY_PAGE.php
Then as a shortcut, you could make EVERY_PAGE.php like this:
<div id="header" class="header">
<img src="Images/metallic.png" width="125" height="125" alt=""/>
<img src="Images/database.png" width="85%" height="125" align="right" alt=""/>
</div>
<?php include 'Parts/upperdivs.php'; ?>
<?php include 'Parts/navigation.php'; ?>
On each page you would do this:
<?php include 'Parts/EVERY_PAGE.php'; ?>
///
// ... Page code here ...
//
Also, it's good to learn some better styles of coding, but this will get the job done in a clean and quick way.
This is my very first question at StackOverflow.
I was trying to post comment in the post Can a Joomla module "know" what position it's in?, but could find no way to do that so I have to post another question here. Any tips regarding how to do this properly is greatly apprieciated.
Anyway, here is my questions:
I tried the code mentioned in the above post but it seemed didn't work. I'm not only quite new to PHP, but also coding, so I'm not sure if it's me or the code. here's what I did to the module's default.php file:
1)to ensure I insert the code at the right place, I insert
<?php echo(print_r($module)); ?>
and it output 1 at the right position;
2)the position-name that I need to determine is "showcase-a", so I insert code
<?php if ($module->position == 'showcase-a'):?>test<?php endif;?>
to the above place, but this time it does't show anything;
3)then I tried this code:
<?php if ($module):?><span>test</span><?php endif; ?>
But still it does't display "test" at the position as I expected.
4)I tried
<?php if (1):?><span>test</span><?php endif; ?>
and the test "test" displays as good. So I didn't code the IF statement wrong.
Now I'm totally lost. Since print_r($module) outputs 1, $module must be positive, why PHP ignore test in 3)? This is just a side question for the sake of PHP learning. What I still need to solve is let the module determine which position itself is in.
Please help. Thank you!
I'm not sure about using it in the template (although it doesn't seem wrong altogether) but my modules oftentimes access the position like this:
$module->position
in the module (so mod_something.php) so try to put it there, if it's available just set a variable and it will be available in the view too.
If $module->position didn't work for you. $module->position may only work for joomla 1.7, 2.5 and + but i'm not sure. $module->position works in joomla 2.5.
Otherwise you need to make a module.php function
Check out the file
/templates/you-template/html/modules.php
For example you make your position the following in your template (for example index.php)
<jdoc:include type="modules" name="header" style="includeposition" />
inside of
/templates/you-template/html/modules.php
You make a function like this :
<?php
function modChrome_includeposition($module, &$params, &$attribs){
//Set a value to $module->position
$module->position='WHATEVER YOUWANT';
?>
<div class="moduletable <?php echo $params->get('moduleclass_sfx').' '.$module->name; ?>">
<?php
if($module->showtitle){
?>
<div class="modtitle">
<div class="fleche">
<span>
<?php
echo $module->title;
?>
</span>
</div>
</div>
<?php
}
?>
<div class="modcontent">
<?php echo $module->content; ?>
<div class="clear">
</div>
</div>
</div>
<?php
}
?>
make different functions names that sets different values if needed.
the function name will match the syle you set:
modChrome_includeposition($module, &$params, &$attribs)
because
style="includeposition"
inside of your jdoc.
I have some divs that I want to display under some specific conditions in every page. I put the calls to them in the footer like this:
<div id="loginpopup" style="display: none;">
<?php
include '/auth/login_form.php';
?>
</div>
<div id="createprofilepopup" style="display: none;">
<?php
include '/auth/create_profile_form.php';
?>
</div>
<?php
// Show div that spins when something is happening
include '/divs/loading.php';
?>
but the urls seem to be mis-pointed. And if I fix the urls on any page, pages in other directory paths will be mispointed. What is the correct way to organize this sort of thing across a site?
Thanks!
By tje way if you want to take a look, the currently broken site is http://www.problemio.com
The way you include the files it loads them from an absolute path (in Linux the root directory). If you want to load them relative to the current script just don't add the leading slash:
include 'auth/login_form.php';