-
Adding another text section to homepage
Hello,
One of my clients wants an editable section of text adding to the bottom of his Zencart homepage for SEO purposes. I am thinking that maybe I could use an EZPage for this task, and just not have it show up on any menus.
So I will need to pop in a bit of PHP to pull the page content from the database and display it on the page. I tried this:
Code:
<?php
$seo_text = "SELECT pages_html_text FROM ezpages WHERE pages_title='SEO'";
print($seo_text);
?>
but it just displayed the text of the query, not the EZpage contents. Sorry for being a n00b, but what would i need to add to make this work?
thanks :D
Nick
-
Re: Adding another text section to homepage
I'm not a mySQL expert, but this adapted from other database queries might work:
PHP Code:
<?php
$seo_text_query = "SELECT pages_html_text FROM ezpages WHERE pages_title='SEO'";
$seo_text = $db->Execute($seo_text_query);
?>
-
Re: Adding another text section to homepage
Hi Glenn,
Thanks for your quick reply, your comments put me on the right track and this code pulls out the EZPage content onto the page:
Code:
<?php
$page_query = $db->Execute("SELECT pages_html_text FROM ezpages WHERE pages_title='SEO'");
$seo_text = $page_query->fields['pages_html_text'];
echo $seo_text;
?>
Cheers for your help :smile:
Nick
-
Re: Adding another text section to homepage
I'm trying to do the exact same thing for one of my clients. Can you tell me which file you edited with the new seo_text code to make the text appear on the home page? Thanks.
-
Re: Adding another text section to homepage
Hi,
I put it in right at the bottom of my tpl_main_page.php that is in my skin file template over-ride folder. The EZ-Page is called SEO. The code/page content could go anywhere I suppose, but my client wanted it off the bottom of the page. Hope this helps :smile:
Nick
Code:
<div id="seo_content">
<?php
$page_query = $db->Execute("SELECT pages_html_text FROM ezpages WHERE pages_title='SEO'");
$seo_text = $page_query->fields['pages_html_text'];
echo $seo_text;
?>
</div>
</body>
-
Re: Adding another text section to homepage
Thanks for the reply. I'm gradually figuring out how this whole cart is assembled. Can you help me find where to post the other piece of code (SELECT code)? Thanks.
-
Re: Adding another text section to homepage
Actually, I got past the question in my previous post but keep getting this error:
1146 Table 'mikoncor_mainstore.ezpages' doesn't exist
in:
[SELECT pages_html_text FROM ezpages WHERE pages_title='SEO']
-
Re: Adding another text section to homepage
I figured it out. Thanks for all the help.
-
Re: Adding another text section to homepage
Glad you got it sorted :P
Nick
-
Re: Adding another text section to homepage
WOW. This is what I have tried to do for some time. Have tried to do it with the defines pages.
I like this solution a lot better. With EZpages you can format the text the way you want and don't need to hard code the whole html into a file like others suggested. I love it. Thank you very much.:clap:
-
Re: Adding another text section to homepage
Oh no! I was celebrating too fast. The text loads now on every page. All I want is that it load on the home page. Any ideas?
-
Re: Adding another text section to homepage
How about a PHP if statement that only pulls that EZ page when displaying the homepage?
Nick
-
Re: Adding another text section to homepage
Yes exactly, can you help me with that? I struggle...
-
Re: Adding another text section to homepage
Probably something like:
HTML Code:
<?php
<div id="seo_content">
if ($this_is_home_page) {
$page_query = $db->Execute("SELECT pages_html_text FROM ezpages WHERE pages_title='SEO'");
$seo_text = $page_query->fields['pages_html_text'];
echo $seo_text;
}
</div>
</body>
?>
-
Re: Adding another text section to homepage
Sorry try again:
HTML Code:
<!--bof- SEO Ezpage text -->
<div id="seo_content">
<?php
if ($this_is_home_page) {
$page_query = $db->Execute("SELECT pages_html_text FROM zen_ezpages WHERE pages_title='SEO'");
$seo_text = $page_query->fields['pages_html_text'];
echo $seo_text;
} ?>
</div>
<!--eof- SEO Ezpage text -->
Seems to work. Does this look correct?
-
Re: Adding another text section to homepage
My PHP skills are sadly lacking, but that seems to make sense! Is that in use on your site now?
I was wondering whether having the same SEO text on each page would actually be harming results instead of helping.. so this could come in handy.
Nick
-
Re: Adding another text section to homepage
I use it for additional text below the category pictures. I don't want the whole blabla taking up most of the page and customers would not even see the pictures. This way, the most important intro text is on top, then pics, then I can put more text for the customer AND search engines to get enough content on the home page.
If you want to put the most important keywords as the last thing on every page, put it in the footer. Too much text that repeats on every page might not be great for SEO.
And yes, I implemented this on the first site in my signature.
-
Re: Adding another text section to homepage
Good stuff! Thanks, I may well use that on an upcoming site :)
Nick
-
Re: Adding another text section to homepage
Hi
Great thread - just what I have been searching for. followed instructions, but is is not working. See bottom of homepage.
http://trulyethical.com
Can anyone help?
Thanks
matt
-
Re: Adding another text section to homepage
I wanted editable text both above and below my featured items and bunyip provided these simple steps:
http://www.zen-cart.com/forum/showpo...31&postcount=6
His solution works perfectly. His method uses define_pages rather than ez-pages.
-
Re: Adding another text section to homepage
Thanks Doug
looks the perfect solution. I've followed all the instructions and get this on homepage
http://trulyethical.com
I'm no expert can you help?
Thanks
matt:unsure:
-
1 Attachment(s)
Re: Adding another text section to homepage
@Matt
I wish I was an expert...
Attached is a zip of the files in the correct directory structure that added an editable area to the bottom of my site. Remember to change the name of custom_template to whatever template you're using so the over-ride goes into the correct directory.
PS - the actual define_main_page_lower file in my attachment has my site content in it.
Good luck.
-
Re: Adding another text section to homepage
This worked for me, (although I am now wanting to do something more)
http://www.zen-cart.com/forum/showthread.php?t=133568
Note location of // NICCOL START & END in includes\templates\your_template\templates\tpl_index_categories.php
Code:
<?php
/**
* Page Template
*
* Loaded by main_page=index<br />
* Displays category/sub-category listing<br />
* Uses tpl_index_category_row.php to render individual items
*
* @package templateSystem
* @copyright Copyright 2003-2006 Zen Cart Development Team
* @copyright Portions Copyright 2003 osCommerce
* @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
* @version $Id: tpl_index_categories.php 4678 2006-10-05 21:02:50Z ajeh $
*/
?>
<div class="centerColumn" id="indexCategories">
<?php if ($show_welcome == true) { ?>
<h1 id="indexCategoriesHeading"><?php echo HEADING_TITLE; ?></h1>
<?php if (SHOW_CUSTOMER_GREETING == 1) { ?>
<h2 class="greeting"><?php echo zen_customer_greeting(); ?></h2>
<?php } ?>
<!-- deprecated - to use - uncomment
<?php if (TEXT_MAIN) { ?>
<div id="" class="content"><?php echo TEXT_MAIN; ?></div>
<?php } ?>-->
<!-- deprecated - to use - uncomment
<?php if (TEXT_INFORMATION) { ?>
<div id="" class="content"><?php echo TEXT_INFORMATION; ?></div>
<?php } ?>-->
<?php if (DEFINE_MAIN_PAGE_STATUS >= 1 and DEFINE_MAIN_PAGE_STATUS <= 2) { ?>
<div id="indexCategoriesMainContent" class="content"><?php
/**
* require the html_define for the index/categories page
*/
include($define_page);
?></div>
<?php } ?>
<?php } else { ?>
<h1 id="indexCategoriesHeading"><?php echo $breadcrumb->last(); ?></h1>
<?php } ?>
<?php
if (PRODUCT_LIST_CATEGORIES_IMAGE_STATUS_TOP == 'true') {
// categories_image
if ($categories_image = zen_get_categories_image($current_category_id)) {
?>
<!--<div id="categoryImgListing" class="categoryImg"><?php echo zen_image(DIR_WS_IMAGES . $categories_image, '', SUBCATEGORY_IMAGE_TOP_WIDTH, SUBCATEGORY_IMAGE_TOP_HEIGHT); ?></div> -->
<?php
}
} // categories_image
?>
<?php
// categories_description
if ($current_categories_description != '') {
?>
<!--NICCOL START-->
<?php $all_the_description = $current_categories_description; ?>
<?php
$xxx_pos = strpos($all_the_description,'###');
if($xxx_pos === false) {
$description_top = $all_the_description;
}
else {
$description_top = substr($all_the_description,0,$xxx_pos);
$bottom_length = strlen($all_the_description)-$xxx_pos-3;
$xxx_pos = $xxx_pos + 3;
$description_bottom = substr($all_the_description,$xxx_pos,$bottom_length);
}
?>
<div id="categoryDescription" class="catDescContent"><?php echo $description_top; ?></div>
<!--NICCOL END-->
<?php } // categories_description ?>
<!-- BOF: Display grid of available sub-categories, if any -->
<?php
if (PRODUCT_LIST_CATEGORY_ROW_STATUS == 0) {
// do nothing
} else {
// display subcategories
/**
* require the code to display the sub-categories-grid, if any exist
*/
require($template->get_template_dir('tpl_modules_category_row.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_category_row.php');
}
?>
<!-- EOF: Display grid of available sub-categories -->
<!--NICCOL START-->
<div id="categoryDescription_bottom" class="catDescContent"><?php echo $description_bottom; ?></div>
<!--NICCOL END-->
<?php
$show_display_category = $db->Execute(SQL_SHOW_PRODUCT_INFO_CATEGORY);
while (!$show_display_category->EOF) {
// // echo 'I found ' . zen_get_module_directory(FILENAME_UPCOMING_PRODUCTS);
?>
<?php if ($show_display_category->fields['configuration_key'] == 'SHOW_PRODUCT_INFO_CATEGORY_FEATURED_PRODUCTS') { ?>
<?php
/**
* display the Featured Products Center Box
*/
?>
<?php require($template->get_template_dir('tpl_modules_featured_products.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_featured_products.php'); ?>
<?php } ?>
<?php if ($show_display_category->fields['configuration_key'] == 'SHOW_PRODUCT_INFO_CATEGORY_SPECIALS_PRODUCTS') { ?>
<?php
/**
* display the Special Products Center Box
*/
?>
<?php require($template->get_template_dir('tpl_modules_specials_default.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_specials_default.php'); ?>
<?php } ?>
<?php if ($show_display_category->fields['configuration_key'] == 'SHOW_PRODUCT_INFO_CATEGORY_NEW_PRODUCTS') { ?>
<?php
/**
* display the New Products Center Box
*/
?>
<?php require($template->get_template_dir('tpl_modules_whats_new.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_whats_new.php'); ?>
<?php } ?>
<?php if ($show_display_category->fields['configuration_key'] == 'SHOW_PRODUCT_INFO_CATEGORY_UPCOMING') { ?>
<?php include(DIR_WS_MODULES . zen_get_module_directory(FILENAME_UPCOMING_PRODUCTS)); ?><?php } ?>
<?php
$show_display_category->MoveNext();
} // !EOF
?>
</div>
The text can then be edited via Admin > Tools > Define Page Editor > define_main_page. (IIRC)
Hope this helps.
-
Re: Adding another text section to homepage
Oh and for the bottom text
<div id="categoryDescription_bottom" class="catDescContent">
in stylesheeet.css, I did this
#categoryDescription_bottom {
width:100%;
margin:0em 0em 0em 0em;
padding:1em 0em 0em 0em;
color:#000;
}
.catDescContent {
}
-
Re: Adding another text section to homepage
I am new to zencart. I would like to add text to the homepage after category images as well. I added your code (thanks), but I get the following error:
1146 Table 'bestorg_zencart.ezpages' doesn't exist in:[SELECT pages_html_text FROM ezpages WHERE pages_title='SEO']
Do you have any idea why?
Thank you for your help