X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   HELP!!!!!!!!!!! (https://forum.x-cart.com/showthread.php?t=3135)

John7 06-11-2003 06:32 AM

HELP!!!!!!!!!!!
 
What would the smarty code need to be just to display the content of the table that holds the email addresses of the newsletter subscribers?

Please help.

Thanks

John

funkydunk 06-11-2003 02:22 PM

Not quite a simple as that really.

The first step is creating a php script that will pull the info from the database and assign it to smarty. You can then display this with a template.

Or you could export the data straight from the database using phpmyadmin if you have it.

kpriest 06-11-2003 03:51 PM

You can use this code I modified from one I created for another purpose:

Code:

<?php

$connection = mysql_connect('localhost', 'YOUR_DB_USERNAME', 'YOUR_DB_PASSWORD');
$db = mysql_select_db("YOUR_DB_NAME",$connection) or die("Could not connect to SQL db");
$sql = "SELECT xcart_customers.firstname, xcart_customers.lastname, xcart_maillist.email FROM xcart_customers INNER JOIN xcart_maillist ON xcart_customers.email = xcart_maillist.email";

$sql_result = mysql_query($sql,$connection) or die ("Couldn't Execute");

echo "  <table width='100%' border='1' cellspacing='2' cellpadding='0'>";
echo "  <tr>
  <td>First Name</td>
  <td>Last Name</td>
  <td>Email</td>
</tr>";

while ($row = mysql_fetch_array($sql_result)) {
$firstname = $row["firstname"];
$lastname = $row["lastname"];
$email = $row["email"];

echo "  <tr>
  <td>$firstname </td>
  <td>$lastname </td>
  <td>$email      </td>
</tr>";
}
echo "</table>";

mysql_free_result($sql_result);
mysql_close($connection);


?>


This pulls the newsletter email addresses out as well as linking to the customer table and getting the first and last name.

Copy this into a text file, fill in your specific database information, save as newsletter_maillist.php or something like that, then post it up in a secure folder on your site (.htaccess protected or something) and just call it up by URL:http://www.yoursite.com/yoursecurefolder/newsletter_maillist.php

A better way would be to use the auth.php and config.php to get access to the db, but I couldn't figure out how to incorporate them into what I was trying to do. I'm fairly new to PHP and MySQL. Maybe funky can add advice on this and how to then assign to smarty if he's so inclined... :D

hth

John7 06-11-2003 07:01 PM

Looks good so far.
 
Looks good so far. Initial tests have been successful.

Will keep you posted.

John7 06-11-2003 08:05 PM

This script works
 
This script works.

Now how do I stick it inside an xcart template?

kpriest 06-11-2003 08:25 PM

Well, that would take me a bit of time to figure out (which I currently don't have at the moment), since it's the part where you would do that smarty stuff.

Sorry to bail on you, but maybe one of the gurus can post a quick reply...

John7 06-11-2003 10:43 PM

I appreciate your help anyways.
 
I appreciate your help anyways.

I can force it to work, but it'll be a little sloppy.


I'm sure it would be a breeze for one of the masters like Funkydunk.

For me so far I can get the job done but it might be a little messy under the hood.

You put me on the right track and your help is greatly appreciated.


Thanks, John

funkydunk 06-12-2003 09:09 AM

okay .... here goes :)

new file:
admin/subscriber_list.php

Code:

<?
/***************************\
a funkydunk creation : 2003
just cos i was taking a tea break - yes I know heather...it's not allowed :) - well it isn't tea really...beer
*/

require "../smarty.php";
require "../config.php";
require "./auth.php";
require "../include/security.php";

// put this to select all subscribers - that was the original post request

// this is the vastly complex query
$query = "SELECT * FROM $sql_tbl[maillist]";

// assign the results of the query to a variable thereby making it an array
$subscribers = func_query($query);

// give it to smarty to play with
$smarty->assign("subscribers",$subscribers);

// assign a value to $main so that the home.tpl knows you want to look at the right template
$smarty->assign("main", "subscribers");

// tell it what template is the placeholder
$smarty->display("single/home.tpl");
?>

in skin1/single/home.tpl

add in to the central area:

Code:

{elseif $main eq "subscribers"}
{include file="admin/main/subscriber_list.tpl"}


new template:
admin/main/subscriber_list.tpl

Code:

{* subscriber_list.tpl - funkydunk 2003 *}
{include file="location.tpl" last_location="Subscriber List"}

{if $smarty.get.usertype eq ""}
{capture name=dialog}
<table border="0" cellpadding="2" cellspacing="0" width="100%">
{section name=subscriber loop=$subscribers}
<tr>
<td valign="top">
<a href=mailto:{$subscribers[subscriber].email}>{$subscribers[subscriber].email}</a>
</td>
</tr>
{/section}
</table>
{/capture}
{include file="dialog.tpl" title="Subscriber List" content=$smarty.capture.dialog extra="width=100%"}
{/if}


kpriest 06-12-2003 09:47 AM

Nice job funky! :D I knew you'd have no problem with this.

funkydunk 06-12-2003 09:56 AM

works on 3.3.x haven't tested on 3.4.x .

thanks

PhilJ 06-12-2003 10:44 AM

might wanna add a link to remove any crap email addresses (updated)

Code:

{include file="location.tpl" last_location="Subscriber List"} {if $smarty.get.usertype
eq ""} {capture name=dialog}
<table onmouseover="this.style.backgroundColor='#f5f5f5';" onmouseout="this.style.backgroundColor='#ffffff';" width="100%" border="0" cellpadding="2" cellspacing="0">
  {section name=subscriber loop=$subscribers}
  <tr>
    <td style="border-bottom: 1px solid #F0F0F0"><a href=mailto:{$subscribers[subscriber].email}>{$subscribers[subscriber].email}</a>
    </td>
    <td style="border-bottom: 1px solid #F0F0F0"><div align="right">Remove</div></td>
  </tr>
  {/section}
</table>
{/capture} {include file="dialog.tpl" title="Subscriber List" content=$smarty.capture.dialog
extra="width=100%"} {/if}



Works on v3.4.3. thanks for the mod :wink:

funkydunk 06-12-2003 10:46 AM

good improvement

John7 06-12-2003 11:29 AM

Thank for your help Funky
 
Thank for your help Funky

But for some reason I'm getting a blank screen.

Probobly somthing simple.

funkydunk 06-12-2003 11:33 AM

did you make the amends in home.tpl?

John7 06-12-2003 11:35 AM

...
 
I added


{elseif $main eq "subscribers"}
{include file="admin/main/subscriber_list.tpl"}

to the central space.


all I have to run is subscriber_list.php and this should work right?

or is there another string involved?

funkydunk 06-12-2003 01:03 PM

admin/subscriber_list.php - once logged into admin

John7 06-12-2003 01:05 PM

Hmm thats what I thought.
 
Hmm thats what I thought.


I wonder why its coming up blank.

By the way did you get my pm?

funkydunk 07-10-2003 10:20 AM

John,

Did we resolve this?

John7 07-10-2003 10:48 AM

Well
 
I'm sure your script works since you tested it and it works for you.

Its got to just be a matter of how the script is installed on my end.

I personally didn't get it to work yet, but havent had time to get back to it in a while. So many other things have come between since. I'll try it again soon with a fresh install.

Thanks

John7

toonarific 07-11-2003 07:42 PM

now, how do we sort it alphabetical for easy email lookup?

funkydunk 07-11-2003 10:06 PM

Code:

// this is the vastly complex query
$query = "SELECT * FROM $sql_tbl[maillist] order by email ASC";


toonarific 07-11-2003 10:57 PM

don't forget the space in

order by

funkydunk 07-11-2003 11:03 PM

edited :)

DataViking 07-11-2003 11:27 PM

THanks for sharing :roll:

toonarific 07-24-2003 04:07 PM

is there also a way to have a running total at the top of the list that shows how many people are subscribed to the newsletter?


one more thing, in the code itself. in the line

{$config.Company.company_website}/mail/unsubscribe.php?email={$subscribers

I had to add the following

{$config.Company.company_website}/xcart/mail/unsubscribe.php?email={$subscribers

since the directory where I keep the cart is xcart, and not directly to the mail folder. just thought Id add that

groovico 08-14-2003 05:20 PM

This thread screams for pointing some people towards marketing manager :wink:

Ok we are now officially asking for more suggestions and ideas for extra add on x-cart modules for MM, any ideas/wishes you have please PM or email them to me, we're taking on board loads and many of the good ones will be developed into low cost add ons.

We've already developed and covered most of the wishes/request for x-cart newsletter list control for exports/imports/edit/deletes etc.


All times are GMT -8. The time now is 08:16 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.