Adamski Posted July 20, 2007 Share Posted July 20, 2007 Hi, I'm going to be restricting access to the downloads page to logged in clients only. I would also like to take that a step further and restrict access to certain downloads depending on what products they have purchased. Is this possible? And if so where would I start? First, checking to see if client is logged in, if they are then checking which products they have, and then displaying each product related download. If not logged in display "You must be logged in to see this page / message". The initial if else is fine, but not quite sure how to do the bit in the middle! Any pointers? Thanks, Adam 0 Quote Link to comment Share on other sites More sharing options...
MACscr Posted July 20, 2007 Share Posted July 20, 2007 create a smarty plugin that checks the db to see if that users has that particular product. 0 Quote Link to comment Share on other sites More sharing options...
Adamski Posted July 20, 2007 Author Share Posted July 20, 2007 After realising I was editing the wrong template I have now got to this stage.. code from downloadscat.tpl {if $downloads && $dlcats.id ==9} TEST {elseif $downloads && $dlcats.id !=9} [b]{$LANG.downloadsfiles}[/b]</p> <table width=100%> <blockquote> {foreach key=num item=download from=$downloads} <tr><td> {$download.type} [url="{$download.link}"][b]{$download.title}[/b][/url] {$download.description} <font style="color:#A8A8A8;font-size:10px;">{$LANG.downloadsfilesize}: {$download.filesize}</font> </p> </td></tr> {/foreach} </table> {else} <p align=center>[b]{$LANG.downloadsnone}[/b]</p> {/if} I'm not sure if "$dlcats.id ==9" is right though so if someone could advise that would be great? Basically at this point I just want to display "test" if the download cat id is 9. At the moment it just displays the available downloads! Thanks, Adam 0 Quote Link to comment Share on other sites More sharing options...
Adamski Posted July 20, 2007 Author Share Posted July 20, 2007 ok i've made progress on this but was wondering if there is way of still using this <table width=100%> <blockquote> {foreach key=num item=download from=$downloads} <tr><td> {$download.type} [url="{$download.link}"][b]{$download.title}[/b][/url] {$download.description} <font style="color:#A8A8A8;font-size:10px;">{$LANG.downloadsfilesize}: {$download.filesize}</font> </p> </td></tr> {/foreach} </table> but specifying it to only display one thing depending on the product. Not the end of the world as I can do it all manually - would just be a much neater solution Ad 0 Quote Link to comment Share on other sites More sharing options...
Adamski Posted July 20, 2007 Author Share Posted July 20, 2007 Hi, Does anyone know how I can use a smarty string when querying the databse? I want to do this: $client_query = "SELECT * FROM tblhosting WHERE userid = '$clientsdetails.id''"; but it doesn't work.... i'm wondering if I need to do something to it first? Cheers Adam 0 Quote Link to comment Share on other sites More sharing options...
trine Posted July 20, 2007 Share Posted July 20, 2007 what is your complete code? did you already connect to the db, and what function are you using to send the $client_query? 0 Quote Link to comment Share on other sites More sharing options...
Adamski Posted July 20, 2007 Author Share Posted July 20, 2007 {if $downloads && $smarty.get.catid == 9} {php} $this->assign('clientid', $clientsdetails.id); $client_query = "SELECT * FROM tblhosting WHERE userid = '$clientid'"; $result = mysql_query($client_query) or die(mysql_error()); $row = mysql_fetch_array($result) or die(mysql_error()); $this->assign('package', $row); {/php} success</p> {elseif $downloads && $smarty.get.catid != 9} [b]{$LANG.downloadsfiles}[/b]</p> <table width=100%> <blockquote> {foreach key=num item=download from=$downloads} <tr><td> {$download.type} [url="{$download.link}"][b]{$download.title}[/b][/url] {$download.description} <font style="color:#A8A8A8;font-size:10px;">{$LANG.downloadsfilesize}: {$download.filesize}</font> </p> </td></tr> {/foreach} </table> {else} <p align=center>[b]{$LANG.downloadsnone}[/b]</p> {/if} It works when i substitute $clientid with the actual number 0 Quote Link to comment Share on other sites More sharing options...
trine Posted July 20, 2007 Share Posted July 20, 2007 first of all I would not do db connections in your templates ... just out of security concerns. Secondly, do as I mentioned in the PM and do this as a plugin. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.