How to write a dynamic homepage?

Reveller

No avatar

2006-02-20 20:47

Currently, my QC1.2 start_page is set in the general.php file to "productsList". I think this is triggering a function that displays the last 5 (or whatever is set) products that have been added to the store.

This is not quite what I want. I would like to write my visitors a "welcome to my store" message on the homepage. I could do this by creating a content page and change the start_page setting to p_5 or whatever. BUT - this isn't an option because I would like to display the productslist below this welcoming message (which is dynamic content). I tried adding php code to the static content page, but it doesn't get parsed.

I have two questions:
- how could I display a welcoming message above the productlisting ONLY on the homepage?
- is there a plugin to show "promoted" products on the homepage?

Thanks in advance for any help!

treewood (OpenSolution)

Avatar: treewood

2006-02-21 06:37

edit index.php and paste:

<?php
if( $p  == $config['start_page'] ){
  
$sWelcomeMsg $tpl->tHtml'welcome_msg.tpl' );
}
?>


after create file templates/welcome_msg.tpl and add some welcome information
after paste variable $sWelcomeMsg to file templates/products_list.tpl in block LIST_HEAD for example:

<div class="category_desc">
$sWelcomeMsg
$sCategoryDesc
</div>

Reveller

No avatar

2006-02-21 13:50

@treewood thanks a lot! I modified your solution a bit because otherwise welcome_msg.tpl also appeared on any other category page:


if( $p == $config['start_page'] && !$_GET['iCategory'] ){
  
$sWelcomeMsg $tpl->tHtml'welcome_msg.tpl' );
}

Reveller

No avatar

2006-02-21 17:13

As for my second question: is it possible to display only "promoted" products on the start_page? Is there a plugin that allows me to select a checkbox in the admin section, to promote a product? I would like to write one myself, but first have to get acquinted with flat files as data storage.

ipodstock

No avatar

2006-02-21 19:05

I've got a followup for this...

If I would like to create a modified homepage as well... being that currently I have a content page set as my homepage, the word 'home' is above the content on that page.

How can I remove this "home" text in the content?

OR

Can I use the parses above and create a .tpl file that will display when you click on "home" in the content navigation bar?

If not, how can I go about doing so?

Reveller

No avatar

2006-02-21 21:32

@ipodstock - this is not a follow-up question. It's hijacking somebody else's topic so you don't have to open YET ANOTHER topic yourself. Could you please try to figure something as easy as this out for yourself and actually helping the community instead of just consuming it's resources?

As for your question: change the appropriate template, or modify the PHP function that constructs the template variables (!)

idaryl

Avatar: idaryl

2007-01-16 07:05

Reveller? did you get this to work OK?

Let me know

Proxivire

No avatar

2007-01-16 10:56

Reveller:

A little tact would be nice here. Not everyone is as informed as you, and it can be quite difficult to get started on this subject, even while reading the forum, if you have little to no basis.

This is after all, a support forum.

-DmD-

lorenww

No avatar

2007-02-02 19:17

I am having problems making this work.
I have

 
$sWelcomeMsg 
$tpl->tHtml'welcome_msg.tpl' );
echo  
$sWelcomeMsg;


in index.php and it does echo the message from the template

then in products_list.tpl I have


<table style='width: 100%; padding: 1px; border: 0px;' cellspacing='0' class='tekst'>
  <
tr>
    <
td style='padding: 5px; width: 100%;' class='h1'>
$aCategory[name]
** 
$sWelcomeMsg **
    </
td>
  </
tr>
</
table>



at this point all I get are the ** ** and no welcome message.

in welcome_msg.tpl I have "hello welcome"

Can someone help me with this

Thank you for the great cart program
Loren

lorenww

No avatar

2007-02-03 14:58

I did get his sorted out using
$sCategoryDescription = $tpl->tbHtml( 'categories_show.tpl', 'INFO' );
as an example.

hany

No avatar

2007-05-12 05:05

Does anybody know how to make this work in QC2.0?? This solution is not working for me.

treewood (OpenSolution)

Avatar: treewood

2007-05-12 10:09

hany - in QC v2.0 paste variable $sWelcomeMsg to templates/products_list.tpl in block LIST_HEAD

hany

No avatar

2007-05-16 04:34

Thank you treewood but I just cannot get this to work. What I get is a fatal error in index.php (Fatal error: Call to a member function on a non-object in index.php). Any idea?? I don't know what I'm doing wrong. I pasted the code in index.php, edited products_list.tpl where I put $sWelcomeMsg in block LIST_HEAD and created welcome_msg.tpl. Do I put just plain text into welcome_msg.tpl or does it need to be formated somehow? Thanks for looking over this.

treewood (OpenSolution)

Avatar: treewood

2007-05-16 15:54

hany - paste this PHP code in index.php after this:

$tpl->setDirTPL );

Back to top
about us | contact