I have created my first WordPress Theme from HTML and I want to add a space to the right hand side of my blog posts with profile information and links to other sites etc..
I am using the below code and it seems to repeat the table td where I would like to add the profile and other information?
Can anyone shed some light on a solution for this?
To see what it looks like.
<table style="width: 1000px; height: 150px" cellspacing="0" cellpadding="0" align="center">
<tr>
<td style="width: 740px">
<table style="width: 740px" cellspacing="0" cellpadding="0" align="center">
<tr>
<td style="width: 200px; height: 44px" background='Date.jpg'>
<h2>
<?php the_time('F jS, Y'); ?>
</h2>
</td>
<td style="width: 540px; height: 44px" background='Title.jpg'>
<h4>
" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?>
</h4>
</td>
</tr>
<tr>
<td colspan="2">
<div class="entry">
<?php the_content(); ?></div>
</td>
</tr>
<tr>
<td style="height: 44px" background='Comments.jpg'>
Posted By <?php the_author_posts_link(); ?>
</td>
<td style="height: 44px" background='Comments.jpg'>
in <p class="postmetadata"><?php _e( 'Posted in' ); ?> <?php the_category( ', ' ); ?></p>
</td>
</tr>
</table>
</td>
<td style="width: 260px">
SIDEBAR AND PROFILE TAGS HERE</td>
</tr>
</table>
How I can fix this issue in the index.php?
The problem is that you're printing your table inside The Loop. That sidebar <td style="width: 260px"> is being printed at every post. It is not a sidebar for all posts, it's just an individual sidebar to each post.
You'll need to read about Theme Development at the Codex to understand theme structures and best practices.
The reference to 1998 made in a comment is that tables are not used for layout purposes since long ago, see Why not use tables for layout in HTML?.
I'd suggest that you search for Starter Themes (like this) to build upon. For complete, exemplary, themes look for WordPress default ones, from Twenty Ten to Twenty Fourteen, to see how themes evolved in the last years.
Related
I am able to get the coding of a website with file_get_contents but I want to be able to get certain values out of the html. This piece of code is always the same but the value between the html tag changes from time to time. This is the HTML Code:
<div class="cheapest-bins">
<h3>Cheapest Live Buy Now</h3>
<table>
<tbody><tr>
<th>Console</th>
<th>Buy Now Price</th>
</tr>
<tr class=" active">
<td class="xb1">XB1</td>
<td>1,480,000</td>
</tr>
<tr class="">
<td class="ps4">PS4</td>
<td>1,590,000</td>
</tr>
<tr class="">
<td class="x360">360</td>
<td>---</td>
</tr>
<tr class="">
<td class="ps3">PS3</td>
<td>2,800,000</td>
</tr>
</tbody></table>
</div>
How would I go about getting the: 1,480,000 .. 1,590,000 .. --- and 2,800,000?
short answer:
find a css selector library such as https://github.com/tj/php-selector
then you could grab all td:last-child elements/innerhtml
for your specific example you could just just
preg_match_all('#<td>(.*?)</td>#', $html, $matches);
mPDF: Hide table row (CSS display:none) not work.
Do you have any suggest?
My code:
<table align="center">
<tr style="display:none">
<td valign="top" align="left">InfoOption1:</td>
<td valign="top" align="left" colspan="2">#InfoOption1</td>
</tr>
</table>
I feel very dirty for posting this suggestion, but it's the best I got working:
<tr><td>...</td></tr>
<div style="display: none;">
<tr><td>...</td></tr>
</div>
The DIV is the working part. Luckily, html validnes for seo isnt relevant for mPDF
It works if you enclose the row you want to hide inside a Div. The div will have a class which have declared hidden property.
<div class='hide_this_row'>
<tr>
<td>...</td>
</tr>
</div>
<!-- CSS file will look like this -->
<style>
.hide_this_row{
display :none;
}
</style>
I've been editing my MyBB portal.php, and up until recently it was displaying fine. I had added a custom welcome block above the recent posts, and it was displaying fine.
Today I went in to tidy up the code, adding new lines (enter) and indents to make the code more legible. Now, after doing this something went badly wrong. Instead of showing the full MyBB page styles, all it shows is the tags like {$header}. Here's the code:
<html>
<head>
<title>{$mybb->settings['bbname']}</title>
{$headerinclude}
</head>
<body>
{$header}
<table width="100%" cellspacing="0" cellpadding="{$theme['tablespace']}" border="0" align="center">
<tr><td valign="top" width="200">
{$welcome}
{$pms}
{$search}
{$stats}
{$whosonline}
{$latestthreads}
</td>
<td> </td>
<td valign="top">
<table border="0" cellspacing="{$theme['borderwidth']}" cellpadding="{$theme['tablespace']}" class="tborder">
<tr>
<td class="trow1">
<span class="smalltext">
<!--Main Welcome Panel-->
<p style="text-align: center;">
<img alt="" src="http://axelcraft.net/images/welcome.png" style="width: 1024px;" /></p>
<p style="text-align: center;">
<span style="color:#696969;"><span style="font-size: 24px;"><em><span style="font-family: hutrmold;">Get ready for a whole new minecraft experience.</span></em></span></span></p>
<!--Slideshow-->
<center>
<iframe src="http://axelcraft.net/images/slides/slideshow.html" width="800" height="320" scrolling="no" frameBorder="0" style="overflow:hidden;"></iframe>
</center>
<!--End Slideshow-->
<p style="text-align: center;">
<span style="font-size:20px;">
<span style="font-family: 'trebuchet ms', helvetica, sans-serif;">
Thanks for visiting AxelCraft! Start by <span style="color:#385947;"><span style="">signing up</span></span> to get the latest news and updates on the server as well as to register for <span style="color:#385947;">contests</span> and <span style="color:#385947;">events</span>!
</span>
</span>
</p>
<!--End Welcome Panel-->
</span>
</td>
</tr>
</table>
<br />
{$announcements}
</td>
</tr>
</table>
{$footer}
</body>
</html>
Now, when you navigate to portal.php, it only shows the {$} tags along with the html paragraph. It's supposed to be showing sidebars and headers left and right like MyBB does. See what I mean here.
Compare that to the normal forum page here.
I can't figure out what's wrong or why it's not displaying properly.
I could be wrong but are you missing an '>' here
<tr><td
<table width="100%" cellspacing="0" cellpadding="{$theme['tablespace']}" border="0" align="center">
<tr><td valign="top" width="200">
How can I Override NyroModal Wrapper.
I dont want to override the css class, we need the ability TO ADD our divs instead of the native WRAPPER div.
On GitHub i found 2 functions: beforeShowCont and filledContent, but i dont know how to override the wrapper using these functions.
And I also found this article on code google, and this is exactly what i want to develop, but it doesnt say how.
<table class="ctools-modal-content">
<tr>
<td class="popups-tl popups-border"></td>
<td class="popups-t popups-border"></td>
<td class="popups-tr popups-border"></td>
</tr>
<tr>
<td class="popups-cl popups-border"></td>
<td class="popups-c">
<div class="popups-container">
<div class="popups-title">
<span id="modal-title" class="modal-title"></span>
<span class="popups-close"><a class="close" href="#">Close</a></span>
<div class="clear-block"></div>
</div>
<div id="modal-content" class="modal-content">HERE WOULD .wrapper OR #nyroModalContent GO</div>
<div class="popups-buttons"></div>
<div class="popups-footer"></div>
</div>
</td>
<td class="popups-cr popups-border"></td>
</tr>
<tr>
<td class="popups-bl popups-border"></td>
<td class="popups-b popups-border"></td>
<td class="popups-br popups-border"></td>
</tr>
</table>
I refer the nyroModal code from here
If you want to override the wrapper class of it, you can do it by following way.
select the main container of the nyroModal.
add the new style for its wrapper.
i.e.
div#nyroModalFull div.wrapper{ /* your own style*/ }
load your own stylesheet after the nyroModal style
I hope this will work for you
I am working on a site that isn't SEO friendly. Specifically, the header.tpl is inserted automatically into every page, with no option to change it based on the content of the page. I.e., whether category = Bathroom or category = Kitchen, etc.
So I need an if/else command, but having trouble figuring it out in this instance, plus the change that goes along with it.
The code on the portfolio_category.php page is as follows, and what needs to change based on vf_category is parts/header.tpl (I can create Bathroomheader.tpl, Kitchensheader.tpl, etc so that relevant tpl has the relevant Title and Description tags for the page).
<?php
$vc_root_friendly = '.';
$vc_root_site = '.';
include_once("$vc_root_site/config.php");
include_once("$vc_includes_folder/IT.php");
$template_body = new HTML_Template_IT();
$template_body->loadTemplateFile("tpl_portfolio_category.html");
include_once("$vc_includes_folder/images.php");
if(!isset($_REQUEST['vf_category'])){
header("location:portfolio.php");
die();
}
//Show header
$template_header = new HTML_Template_IT();
$template_header->loadTemplateFile("parts/header.tpl",true,false);
$template_body->setVariable('header', $template_header->get());
//Show footer
$template_footer = new HTML_Template_IT();
$template_footer->loadTemplateFile("parts/footer.tpl",true,false);
$template_body->setVariable('footer', $template_footer->get());
$template_body->setVariable("image_category", $_REQUEST['vf_category']);
//Select photos for this category
etc.
Complicating things there is another page referenced in the code above:
tpl_portfolio_category.html
And this page too has its own header.tpl include:
<? include_once 'parts/header.tpl'; ?>
{header}
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td class="main"><h1><span class="firstLetter">{image_category}</span></h1>
<p>
</p>
<table height="89" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td colspan="7"> </td>
</tr>
<!-- BEGIN block_thumb -->
<tr>
<td width='180' height="120" background="./images/thumb-bg.gif"> <div
align="center">{thumb1}</div></td>
<td width="10"> </td>
<td width='180' background="./images/thumb-bg.gif"> <div align="center">{thumb2}
</div></td>
<td width="10"> </td>
<td width='180' background="./images/thumb-bg.gif"> <div align="center">{thumb3}
</div></td>
<td width="10"> </td>
<td width='180' background="./images/thumb-bg.gif"> <div align="center">{thumb4}
</div></td>
</tr>
<tr valign="bottom">
<td height="3"></td>
<td height="3"></td>
<td height="3"></td>
<td height="3"></td>
<td height="3"></td>
<td height="3"></td>
<td height="3"></td>
</tr>
<!-- END block_thumb -->
</table>
<br>
<img src="images/spacer.gif"></td>
</tr>
</table>
{footer}
Any guidance would be appreciated! I'm just trying to get parts/header.tpl to change to parts/Bathroomheader.tpl or parts/Kitchenheader.tpl based on the vf_category pulled from the database. But it's driving me nuts.
Thanks in advance,
Gary
there are a few ways to do this, but in order to minimize the number of files you're changing, I suggest that you:
a) Pull the variable from the database and assign it to smarty, on your first php file, for both the header and body:
//Assuming you have retrieved $vf_category from your database;
$template_header->setVariable('vf_category', $vf_category);
$template_body->setVariable('vf_category', $vf_category);
b) Edit your file header.tpl and append the following code at the top:
{if 'vf_category' == 'some_value'}
{include file="parts/Kitchenheader.tpl"};
{elseif 'vf_category' == 'other_value'}
{include file="parts/Bathroomheader.tpl"};
{else}
//the rest of the header.tpl code goes here
{/if}