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??




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


    if ($_product_id = array(1)

    elseif ($_product_id = array(2)

    elseif ($_product_id = array(3)

    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.

  2. abbeyvet

    abbeyvet New Member

    Feb 2, 2003
    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

    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?

  5. abbeyvet

    abbeyvet New Member

    Feb 2, 2003
    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.

  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='[/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.

  8. abbeyvet

    abbeyvet New Member

    Feb 2, 2003
    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:

    while another would be

    '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,
  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?


Share This Page