Re: [PHP] question about smarty

2009-11-05 Thread Fernando Castillo Aparicio
I'm not sure where is the problem, but can't you just define every changing 
part in your template as variables and assign them as needed from php?

If you need to change the image url, just make it a variable, like in

background:url(images/{$img})

Then you just assign the variable as needed in each file:

//template1.php
$img = 'mi_image_1.gif';
$smarty-assign( 'img', $img );

//template2.php
$img = 'mi_image_2.gif';
$smarty-assign( 'img', $img );

That way you don't need to use the {if} inside smarty and make your template 
lighter.





De: Sudhakar sudhakarar...@gmail.com
Para: php-general@lists.php.net
Enviado: vie,6 noviembre, 2009 00:14
Asunto: [PHP] question about smarty

i am using smarty template engine at work place, following is the situation


i already have 1 template that has already been created example =
http://localhost/sites/template1.com this works fine

following is the folder structure i have for smarty on xampp

1. C:\xampp\htdocs\sites\template1.com where i have .htaccess index.php and
siteconf.php

2. C:\xampp\htdocs\sites\_templates\templates\template1


in the siteconf.php file there are all the major variables defined which are
accessed in other tpl file of the templates example in aboutus page,
contactus page etc of this template1

now i have created another template called template2 and this also has the
same structure

1. C:\xampp\htdocs\sites\template2.com where i have .htaccess index.php and
siteconf.php

2. C:\xampp\htdocs\sites\_templates\templates\template2


my question is the look and feel when i access
http://localhost/sites/template1.com and
http://localhost/sites/template2.com

is the same the only thing that needs to be done is for template2 when i
access http://localhost/sites/template2.com ONLY the header image should be
different compared to the header i have for
http://localhost/sites/template1.com this is the only change i need

i am not aware as to the php code i need to write so that when i access
http://localhost/sites/template2.com the header image changes and this new
header image remains for the entire pages of
http://localhost/sites/template2.com

presently in header.tpl of template1 is written as follows

{if strpos($Data.KEYWORD,rv rental) === false}
div class=header
style=background:url(images/header_{$siteData.COUNTRY3}.gif) no-repeat top
left;
{else}
div class=header
style=background:url(images/header_{$siteData.COUNTRY3}_rv.gif) no-repeat
top left;
{/if}
/div

so i need to chane the {if} {else} where i need to mention that if i am
accessing http://localhost/sites/template2.com then the header image should
be different.

any help will be greatly appreciated.

please advice.

thanks.



  

Re: [PHP] Preview button to show PDF without submitting post data?

2009-11-05 Thread Fernando Castillo Aparicio
You could just open in a new window a php script that generates the preview 
pdf with a content-type header for pdf.

header(Content-type: application/pdf);

Or if the preview pdf is not dinamic, just point the url to the pdf.

No javascript needed, just a link, o a submit button on a form with the
url as the action attribute. If you need it to open on a new window,
use target=_blank, or better target=pdf if you want consecutive
requests to open in the same window instead of a new one everytime.

Note: if you are not using transitional html and care about validation, the 
target attribute is not allowed. In that case you would need javascript to open 
a new window.





De: Dave M G mar...@autotelic.com
Para: PHP-General List php-general@lists.php.net
Enviado: vie,6 noviembre, 2009 04:58
Asunto: [PHP] Preview button to show PDF without submitting post data?

PHP Users,

I have a page that generates a PDF document using PHP. It takes form
data filled in by the user to fill out the PDF

When the user clicks submit, it emails that PDF document to the
intended recipient.

However, I would like to add a preview function as well. But for a
variety of reasons, instead of submitting the form data through post and
re-filling all the fields with the selected data, I'd like to be able to
open a new window with an example PDF without actually submitting the form.

I think this might need JavaScript, but I'm not sure.

Is this possible?

Thank you for any advice.

-- 
Dave M G

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


  

Re: [PHP] What PHP version are you using?

2009-10-29 Thread Fernando Castillo Aparicio
5.2.8, but testing 5.3 in local environment.



  

Re: [PHP] regex for multiple line breakes

2009-10-14 Thread Fernando Castillo Aparicio
You are replacing 1 or more matchs of a new line. To match 2 or more you can 
use {2,}. It's a range, first number means min matches, second max matches. 
Omitting last number means no max limit.

$data[txt] = preg_replace('`[\r\n]{2,}`',\n,$data[txt]);




De: Merlin Morgenstern merli...@fastmail.fm
Para: php-general@lists.php.net
Enviado: mié,14 octubre, 2009 12:17
Asunto: [PHP] regex for multiple line breakes

Hi there,

I am trying to remove multiple linebreakes from a textarea input. Spammers tend 
to insert multiple line breakes. The problem is, that I want to allow 2 line 
breaks so basic formating should be allowed.

I am doing this by regex:
$data[txt] = preg_replace('`[\r\n]+`',\n,$data[txt]);

I would need a regex that allows \r\n\r\n, but not more than this.

Thank you for any help,

Merlin

-- PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


  

Re: [PHP] regex for multiple line breakes

2009-10-14 Thread Fernando Castillo Aparicio
Right. I saw it later. To be completely multiplatform I'd use a grouping: 
(\n|\r|\r\n){2,}. If I'm not wrong, these are all the actual formats for a new 
line.

If we replace \r with a newline we could fail if the text comes from a MAC OS.





De: Ashley Sheridan a...@ashleysheridan.co.uk
Para: Merlin Morgenstern merli...@fastmail.fm
CC: php-general@lists.php.net
Enviado: mié,14 octubre, 2009 12:44
Asunto: Re: [PHP] regex for multiple line breakes

On Wed, 2009-10-14 at 12:42 +0200, Merlin Morgenstern wrote:

 That sounds very logical but does not work unfortunatelly.
 The result is the same. It removes all linebreakes but one.
 I would like to pass this one:
 
 -
 first line
 
 second
 third
 -
 
 But not this one:
 -
 third
 
 
 
 
 forth
 
 
 
 
 Fernando Castillo Aparicio schrieb:
  You are replacing 1 or more matchs of a new line. To match 2 or more you 
  can use {2,}. It's a range, first number means min matches, second max 
  matches. Omitting last number means no max limit.
  
  $data[txt] = preg_replace('`[\r\n]{2,}`',\n,$data[txt]);
  
  
  
  
  De: Merlin Morgenstern merli...@fastmail.fm
  Para: php-general@lists.php.net
  Enviado: mié,14 octubre, 2009 12:17
  Asunto: [PHP] regex for multiple line breakes
  
  Hi there,
  
  I am trying to remove multiple linebreakes from a textarea input. Spammers 
  tend to insert multiple line breakes. The problem is, that I want to allow 
  2 line breaks so basic formating should be allowed.
  
  I am doing this by regex:
  $data[txt] = preg_replace('`[\r\n]+`',\n,$data[txt]);
  
  I would need a regex that allows \r\n\r\n, but not more than this.
  
  Thank you for any help,
  
  Merlin
  
  -- PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
  
  
   
 


You still have an issue with your regex:

$data[txt] = preg_replace('`[\r\n]+`',\n,$data[txt]);

Even if you replace the + with a {2,} you are asking it to match any one
of the characters in the square brackets twice or more and replace it
with a single \n. If your line breaks actually do consist of the \r\n
pattern, then the {2,} will match those two characters, not two sets of
those characters. You might be better off replacing all \r characters
with an empty string, and then matching against the \n character only.

Thanks,
Ash
http://www.ashleysheridan.co.uk


  

Re: [PHP] Newbie: Array of objects iteration

2009-10-09 Thread Fernando Castillo Aparicio
I think you are just looking for the key in the wrong place. Try:

foreach ( $records as $record ) {
foreach( $record as $column=$value ) {
echo $column is $value\n;
}
}

You've got the columns names in each record, not in the global recorset.

Good luck ;-)





De: MEM tal...@gmail.com
Para: php-general@lists.php.net
Enviado: jue,8 octubre, 2009 22:59
Asunto: [PHP] Newbie: Array of objects iteration

Hello all,

I'm grabbing all records from a table using:

$records = $stmt-fetchAll(PDO::FETCH_OBJ);
return $records;


In order to display the values we can do:


foreach ($records as $record)
{
echo $record-id;
echo $record-name;
}


However, I'd like to grab, also, the *column names*.

I've tried:

foreach ($records as $column=$value)
{
echo $column is $value\n;
}

But I get:
Catchable fatal error: Object of class stdClass could not be converted to
string



Can I have your help on how can I properly get the column values?

Regards,
Márcio


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


  

Re: [PHP] Newbie: Array of objects iteration

2009-10-09 Thread Fernando Castillo Aparicio






De: MEM tal...@gmail.com
Para: Lester Caine les...@lsces.co.uk; php-general@lists.php.net
Enviado: vie,9 octubre, 2009 12:40
Asunto: RE: [PHP] Newbie: Array of objects iteration

@LinuxManMikeC and all @All
Thanks. I was more or less aware of that possibility, however, please let me
share the big picture will you guys: 

The main point is to access the properties name as well as values, of that
object, and put them on a xls file.
Instead of using mysql_num_rows, and mysql_num_files, and split and use a
bunch of loops I thought: 
Maybe fetching as an object may help me doing this far better. 
However, I'm having a hard time figuring out how to make the switch. 


To be honest, I don't really know if iterate is the buzz word here, I
would like to understand a little bit more the following:

We have in our hands an Object returned by a Fetch_All w/ fetch_obj option
applied to it, that object, when I do var_dump, reveals himself as in
object, containing an array and, each key of that array corresponds the
column names of our table or tables we have previously fetched. 
However, since we are working with an object, should we think differently
than if we were working with an array? If so, it is, in the fact, iteration,
the best option we have to put all properties and values into a xls file? Or
there are far better options for that?



@Lester
Yes, actually, I was having only one record on the database, but I believe
that is far to less. Since I was not been able to see if I was getting one
object, or several objects. That make me think of that. Thanks :) And
because of that, I was able (I hope) to properly understand Fernando
example:



@Fernando
foreach ( $records as $record ) {
foreach( $record as $column=$value ) {
echo $column is $value\n;
}
}
So the first foreach will iterate over each object of stdClass that
corresponds to each record of mysql data fetched, then, for each of them,
take the associative array key and the corresponding value...
Correct? :DDD




However, is this the right track to archive the goal stated above, or, they
are far better ways for doing so?



Regards,
Márcio

-


Correct about my example, although I'm not sure if you get each record as an 
array or as an object. Anyway, you can iterate both.

And if you want to get the column names, I suppose you could use array_keys() 
on the first record if you receive an array, or maybe get_object_vars() if it's 
an objecs (note that with this you get an array with keys and values).

I've found PDOStatement-getColumnMeta(). There's a big fat warning saying this 
is experimental, but you could take a look in case you need more data on the 
columns.

Hope it helps.



  

Re: [PHP] html email showing br instead of line breaks

2009-09-24 Thread Fernando Castillo Aparicio
Have you tried http://es.php.net/manual/en/function.nl2br.php ?

I think it's easier and fits your needs.





De: Adam Williams awill...@mdah.state.ms.us
Para: PHP General list php-general@lists.php.net
Enviado: jueves, 24 de septiembre, 2009 20:52:13
Asunto: [PHP] html email showing br instead of line breaks

I have users enter support tickets into a a textarea form and then it emails 
it to me, I'm trying to get the emails to display when they hit enter 
correctly, so i'm changing the \r\n to br, but in the email i'm getting, its 
displaying the br instead of a line break:  here is the code:

$message = htmlheadtitlenew support request 
#.mysqli_insert_id($mysqli)./title/headbodyp
Hello, .$_SESSION[full_name]. has created a  new support request.  Please 
log in at a href=\http://intra/helpdesk\;MDAH Helpdesk/a. The problem 
request is \;
$message .= htmlspecialchars(str_replace('\r\n', 'br', $_POST[problem]));
$message .= \ and the best time to contact is 
\.htmlspecialchars($_POST[contact_time]).\ /p/body/html;
   $headers  = 'MIME-Version: 1.0' . \r\n;
   $headers .= 'Content-type: text/html; charset=iso-8859-1' . 
\r\n;
   $headers .= From: 
.$_SESSION[full_name]..$_SESSION[username].@mdah.state.ms.us .\r\n 
.
   X-Mailer: PHP/ . phpversion();
  mail('isst...@mdah.state.ms.us', $subject, $message, $headers);

but the email I get is:

Hello, Karen Redhead has created a new support request. Please log in at MDAH 
Helpdesk http://intra/helpdesk. The problem request is Elaine is out today 
but her computer no longer has Past Perfect from what I can tell. Also how does 
she access her email. The Sea Monkey email icon does not take you 
anywhere.brThanks so much,brKaren and the best time to contact is 1:30 
-5:00


How come the email is being displayed with br instead of line breaks?


  

Re: [PHP] Question: Wai-aria?

2009-09-22 Thread Fernando Castillo Aparicio
Ups! By mistake I didn't reply to all. Resending. Sorry.





De: Parham Doustdar parha...@gmail.com
Para: php-general@lists.php.net
Enviado: martes, 22 de septiembre, 2009 9:41:44
Asunto: [PHP] Question: Wai-aria?

Hello there,
I
have asked on the mailing lists that have blind users and no one seems
to know about this technology (that is ironically created to help us
blind folks). I was wondering if anyone here has the experience of
implementing Wai-aria. Since my question is rather about Wai-aria than
PHP and is off-topic, I'm first of all sorry to be posting it here (it
is rather an act of desperation). Secondly, I ask people who have the
time to help me to please contact me off-list at parham90 at gmail dot
com.
Thanks.
-- 
---
Contact info:
Skype: parham-d
MSN: fire_lizard16 at hotmail dot com
GoogleTalk: parha...@gmail.com
Twitter: PD90
email: parham90 at GMail dot com


Have you tried the contact section for WAI at w3.org? 
http://www.w3.org/WAI/contacts

They have a WAI Interest Group mailing list (w3c-wai-ig-requ...@w3.org, 
suscribe as subject), and I believe that would be the best place to look for 
help.

Good luck.