Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I got a simple PHP code like this one:
<div id="master">
<div id="info">
<?php include 'division.php';
echo $winrate;
?>
</div>
<div id="lastmatches">
<?php include 'lastmatches.php';?>
</div>
</div>
</body>
As you see i want to echo $winrate, but $winrate is a variable that comes from lastmatches.php. So it will never work. Some has got an idea to echo $winrate in the div info? Im stuck and i hope you guys can help me out!
Thanks in advance!
You need to include lastmatches.php before to define $winrate.
But if this file outputs some content then you will want to use the caching system to output the right content at the right place.
<div id="master">
<div id="info">
<?php include 'division.php';
// begin cache
ob_start();
include 'lastmatches.php';
// end cache
$lastmatchescontent = ob_get_clean();
echo $winrate;
?>
</div>
<div id="lastmatches">
<?php echo $lastmatchescontent; ?>
</div>
</div>
</body>
i suggest you to follow MVC approach, if you do not want to use framework u can do something like this: https://github.com/LPodolski/basic_php_templating
this will allow code to be more readable, by separating concerns of generating output from getting data from db, parsing it etc
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
Edit: Fixed, moved <?php include(haeder.php); ?> to the top and replaced the outsourced part with <?php showheader(); ?>.
I've been creating a little website, and as its menubar started to get full I wanted to "outsource" it to a separate file.
<body>
<div style="width:800px;margin:0px auto">
<!-- outsourced part -->
<div style="height:50px;background-color:#ff0000">
Header
</div>
<!-- end of outsourced part -->
<div style="margin-top:10px;background-color:#00ff00">
hello world
</div>
</div>
</body>
So I copied the outsourced part and pasted it into a new file called header.php and replaced it with
<?php include("header.php") ?>
so now the code is
<body>
<div style="width:800px;margin:0px auto">
<?php include('header.php') ?>
<div style="margin-top:10px;background-color:#00ff00">
hello world
</div>
</div>
</body>
Now when I open the website again the header and everything after it has moved downwards. How can I prevent this from happening? I have PHP 5.6.14 installed on XAMPP and PHP 5.3.3 on a Linux server.
Uploaded the 2 files here
I tested your file and I could see the issue. Usually this is because you got an invisible character in the page. So go into the Chrome debugger, Elements view, and expand the code. You'll find the following before your header <div> tag.
"
"
from the debugger, you can delete it, and you'll see your page displays fine again. So cleanup your 2 php file. One is having an invisible character.
I believe the reason is that your index.php file in UTF8-BOM encoded while the header.php is just UTF8 - make sure to use the same encoding to avoid these issues.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have a website in which I use just html, but I'd like to add one location where I would edit things like the nav and the footer. Then it would be instantly updated across the whole site.
So, for example, I'd like to put:
<nav>
<div class="nav-wrapper">
Logo
<ul id="nav-mobile" class="right hide-on-med-and-down">
<li>Sass</li>
<li>Components</li>
<li>JavaScript</li>
</ul>
</div>
</nav>
Into
<?php echo $nav;?>
Any help would be greatly appreciated! =)
Add the html that you want to show into a file. For eg:
add this to menu.html
<nav>
<div class="nav-wrapper">
Logo
<ul id="nav-mobile" class="right hide-on-med-and-down">
<li>Sass</li>
<li>Components</li>
<li>JavaScript</li>
</ul>
</div>
</nav>
Now include this page in other HTML pages wherever you want to call it like below
<?php
include 'menu.html';
?>
I like Lal's answer. I would change include 'menu.html'; with include_once 'menu.php'; The idea is that you will can add some php variables if you need them on some point.....
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Can someone please break this line down for me.
<div class="container" class="<?php wpp_css('property::content', "property_content"); ?>" role="main">
Many thanks.
Explanation:
<div
It's a div element
class="container"
with the CSS class container.
class="<?php wpp_css('property::content', "property_content"); ?>"
This is wrong! An element can have only one class attribute!
But it seems that you try to add custom CSS classes with the PHP function wpp_css.
role="main">
Your div has the attribute role with value main. More info about roles here.
Corrected div:
<div class="container <?php wpp_css('property::content', "property_content"); ?>" role="main">
wpp_css is a function, first parameter is 'property::content' second parameter is "property_content"
i think it is used to pass the right content to the container
You create a div with a dynamic class. The class is being generated ny a PHP function called wpp_css and the div's role is main
I am guessing your using "WordPress Popular Posts" plugin and the method wpp_css() is a method of this plugin to determining which CSS class should be applied to your container div.
It first checks that whether any value is set for the 'property::content' property or not. If it is set then it returns that otherwise it returns 'property_content'.
You also have two class attributes in your div. You should change them like this.
<div class="container <?php wpp_css('property::content', "property_content"); ?>" role="main">
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I've such piece of code:
<xsl:template match="bottom">
<div class="l1">
<div class="l2">
<div class="fl100">
<div align="center">
<div class="mw" align="center">
<div class="footer">
<div class="f1">$-BOTTOM_COPY-$</div>
<div class="f2">
$-BOTTOM_CONTACTS-$
</div>
<div class="f3">
$-BOTTOM_LINKS-$
</div>
<div class="f4">
$-BOTTOM_STUDY-$
</div>
</div>
</div>
</div>
</div>
</div>
</div>
I cannot understan where from $-BOTTOM_CONTACTS-$, $-BOTTOM_LINKS-$ etc variables are.
I'm new in xsl, and searched every src files, but didn't find any declaration of define in php code.
Any idea?
It looks to me as if someone has included these bits of text (like $-BOTTOM_STUDY-$) as a target for replacement with something specific. Either they intended them to be replaced in the stylesheet before running the transformation, or they intended them to be replaced in the output file after running the transformation. But as far as XSLT is concerned, they are just strings to be copied from the stylesheet to the result document.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
i want to display the image of posts in other div then content's one.
I mean like this.
<div class="latest-posts">
<div class="latest-posts-info">
<div class="title"><h1>HERE IS TITLE<h1></div>
<div class="text">HERE IS CONTENT</div>
Read more...
<div class="clear"></div>
</div>
<div class="latest-posts-img">HERE I WANT THE IMAGE</div>
<div class="clear"></div>
</div>
While was adding a post in wp admin, i noticed its the only way, displaying image IN content.
Thanks
Check out this page : http://codex.wordpress.org/Function_Reference/the_post_thumbnail
<div class="latest-posts-img"> <?php the_post_thumbnail( $size, $attr ); ?> </div>
You can try to add a custom template for this post using this function:
http://codex.wordpress.org/Function_Reference/wp_get_attachment_image