Single Product Template Page With Variable Content

Discussion in 'Customization & add-ons' started by petroski, Sep 3, 2003.

  1. petroski

    petroski Guest

    Hello All,

    Please bear with me, I'm new at this, please be gentle! :) I've looked around the forums and I can't quite find anything similar.

    I would like to create a single product page (template) for all product categories that will assign variable content according to the member's assigned product category. This page acts as a template for all members and would make things much easier to manage. (edit one master template file instead of many multiple files that are basically the same).

    As every member logs on, they are routed to this single template file and assigned their product content on the fly.

    So far, this is what I've come up with but, it's not working! :(


    ////////////////////////////////////////////////////////

    // For the top of the master template page

    <?
    session_start(); // need to be called once
    ?>

    <?

    $_product_id = array(1,2,3); // This is so that multiple user product categories can access this page??

    include("/home/httpd/vhosts/mydomain.com/httpdocs/amember/plugins/protect/php_include/check.inc.php");

    ?>


    //////////////////////////////////////////////////////////

    //Variable Content Section, depending on Logged In User's Product Assignment

    <?

    if ($_product_id = array(1)
    {
    include("pageone.php");

    }
    elseif ($_product_id = array(2)
    {
    include("pagetwo.php");

    }
    elseif ($_product_id = array(3)
    {
    include("pagethree.php");

    }
    else
    {
    print "There has been an error. Please log on again";

    }

    ?>


    //////////////////////////////////////////////////////////////////////////

    I thought that this might be a useful exercise since others may use this besides myself? BTW. An excellent piece of scripting work, I will be purchasing the full version, even if I can't get the above to work.

    Thanks for any help.

    Petroski
  2. abbeyvet

    abbeyvet New Member

    Joined:
    Feb 2, 2003
    Messages:
    135
    That's what happens anyway isn't it? Or am I missing something?

    When users buy a product (ie access to some content or whatever) the link to that product is included on their member profile page. If they didn't buy it, it does not appear. So if member A bout products 1, 3 and 5 those links appear when he/she logs in. Wheras member B who bought products 2,4 and 6 will see those products only.

    Or, again, am I missing something?
  3. alex-adm

    alex-adm Guest

    petroski,
    please try to use
    amember/login.php - it should do exactly what you need, but simpler.
  4. petroski

    petroski Guest

    The difference is that all members, once logged in, would go to the same "master" template page (all members are forwarded to the same category page URL) but, according to their product category, they are then assigned to their content within the template.

    So..., what I was trying to do was to use an if and ifelse statement to call one of the various includes based on that member's product category.

    By doing it this way, you would have a global template overlay in one single file rather than many product category files. Saves a lot of time if you wanted to make modifications to the template.

    This also allows themes or skins, since one could then route members to various theme's template files but still have the proper content included into that template's framework.

    Am I making any sense?

    :unsure:
  5. abbeyvet

    abbeyvet New Member

    Joined:
    Feb 2, 2003
    Messages:
    135
    Sort of :D

    Which is what they do anyway. They go to member.php (unless you have configured it to be otherwise.)


    By default they are then presented with a list of all the products they have purchased. You can easily alter the way this list is displayed by editing /templates/member.html or member_multi.html as appropriate.

    You can also easily add another field, which you would fill in the add product screen of aMember, and that will display on the member.php page with each purchased product. In that you could add any HTML that you want.

    The theme thing would require a bit more than that alright. I can see a few ways that it could be done, but not if there was the potential that a user might have more than one product .
  6. petroski

    petroski Guest

    Hello Alex,

    I'm not quite sure how using login.php would work in this situation? Can you give me a clue? Are you saying that the code in login.php can be modified for my purposes?

    Thanks Alex for your help.

    Petroski
  7. petroski

    petroski Guest

    Hi abbeyvet,

    Oops, sorry I missed your post this morning! :rolleyes:

    OK, each member has only one product available to them, there would be no members with instances of multiple products.

    Yes, they go to member.php and then they are assigned to a product page. No problem there.

    I want to route everyone to the same product page (the template page), but then, according to their product_id, they are assigned (by an include) the content that fulfills their product request.

    For a simple example:

    The template page has a picture, editorial content, theme style, etc. that I want all members to see.

    Below that picture I want a variable content section to appear, based on the members product_id.

    I would have a number of different content.php files (content01.php, content02.php, content03.php) to be called by an if/ ifelse (?) statement from the template page that would insert the correct content based on the member's product_id.

    Follow me here?

    The template page formats the content. Yes, I could "include" the template from the various content files, but then I am limited to only the one theme. I want to leave open the option of multiple themes to enclose the various content products within. See image below.

    <img src='http://www3.telus.net/pfullerton/amember/amember_routing.jpg[/img]

    the members are directed to a theme template by the URL in the product setup page.

    the content is called by the member's assigned product_id

    Can this be done?

    Maybe I'm thinking backwards on this, but maybe not.

    Petroski
  8. abbeyvet

    abbeyvet New Member

    Joined:
    Feb 2, 2003
    Messages:
    135
    I am sure it can be done. It really would be a matter for add-on coding though, nothing to do with aMember.

    I am no PHP expert though, so I am not sure exactly how but the following occurs to me.

    When you add a product, provide no link to the protected area (ie leave that box in the add product screen blank). Instead add a new custom field which will appear on the member.php page, and put a link to the protected page in here. This link is what will appear in member.php when the user arrives that far.

    That link can include variables, which will be passed to the page and will determine the theme and the content. How you set that up is a matter for yourself, as I say, it would be outside the remit of amember.

    For example the url to one product might look like:

    http://www.example.com/dir/page.php?...eme=1&content=4

    while another would be

    http://www.example.com/directory/page.php?...eme=3&content=6

    'course you will need a script to call the theme and the content from a DB, but that should not be so hard.
  9. Guest

    Guest Guest

    Thanks abbeyvet,

    You are correct, this isn't about modifying amember, it's doing exactly what I need it to do. And I know what you are saying about using php link variables to assemble pages, but that's not quite what I'm trying to accomplish.

    From other posts, I was able to look at the session data and, yes, the product_id is there.

    Given the product_id contained in the session data, I want to be able to call a page from an array(?) of product pages and include that into my master template page.

    I'm going to give this another weekend of pounding my php resource book and see what I can come up with. Php is a "brave new world" for me. :blink:

    Muchas gracias,
    Petroski
  10. petroski

    petroski Guest

    OK everyone, I figured it out. It's a simple solution, of course! :rolleyes:

    I used the php include statement to insert the header and footer of the template page with the variable content section. That way, the customer is directed to the correct variable content section through aMember and they get the correct page template.

    Easy, huh?

    :blink:

Share This Page