Go Back   WarriorForum - Internet Marketing Forums > Warrior Support Forums > Programming Talk
Register Blogs FAQ Social Groups CalendarHelp Desk

Reply
 
LinkBack Thread Tools
Old 11-16-2009, 07:31 AM   #1
Edmund Lee
War Room Member
 
edmltw's Avatar
 
Join Date: Jul 2009
Location: Singapore
Posts: 624
Blog Entries: 2
Thanks: 124
Thanked 91 Times in 57 Posts
Social Networking View Member's Myspace Profile  View Member's YouTube Profile
Contact Info
Send a message via Skype™ to edmltw
Default PHP Issue: How Do I insert raw HTML into .PHP scripts?

The situation is like this:

I am using a shopping cart script that is coded in .php , and I want to add on a google analytic script to the index.php .

How do I actually add the raw html coding into the .php file?

Regards,
Ed

edmltw is offline   Reply With Quote
Old 11-16-2009, 07:48 AM   #2
Spartan Warrior
War Room Member
 
Join Date: Jul 2008
Location: PH
Posts: 903
Thanks: 122
Thanked 144 Times in 72 Posts
Default Re: PHP Issue: How Do I insert raw HTML into .PHP scripts?

If it's inside the PHP code you should use something like:

echo '<b>this is html';

If it's outside, you can simply put it straight away.


Mark Brian is offline   Reply With Quote
Old 11-16-2009, 07:53 AM   #3
HyperActive Warrior
War Room Member
 
Join Date: May 2009
Location: U.K
Posts: 197
Thanks: 5
Thanked 39 Times in 36 Posts
Social Networking View Member's Twitter Profile 
Default Re: PHP Issue: How Do I insert raw HTML into .PHP scripts?

This is a simple request, but you will need to do this somewhere suitable in the script - I.E
somewhere that is not in a loop, and if statement and such.


If you want to do this at the end of the script, you can do this after the closing PHP tag, which is ?> - however, this may not be the best place for it.

If you need to insert it before the end of the PHP script, you will need to

close the tag; ?>
Paste in your HTML
and then reopen the tags <?php


Alternatively, and this may be the safer option for you, if you do not want to break the php tags you can simply do the following in a suitable location.

print <<<GACODE

paste your GA code in here

GACODE;


If the index.php has a footer section, this would be an ideal location, just before the closing </html> tag.

Best Ways To Make Money Online

Eight bytes walk into a bar. The bartender asks, “Can I get you anything?”
“Yeah,” reply the bytes. “Make us a double.”
Luke Graham is offline   Reply With Quote
Old 11-16-2009, 08:00 AM   #4
Edmund Lee
War Room Member
 
edmltw's Avatar
 
Join Date: Jul 2009
Location: Singapore
Posts: 624
Blog Entries: 2
Thanks: 124
Thanked 91 Times in 57 Posts
Social Networking View Member's Myspace Profile  View Member's YouTube Profile
Contact Info
Send a message via Skype™ to edmltw
Default Re: PHP Issue: How Do I insert raw HTML into .PHP scripts?

Quote:
Originally Posted by Mark Brian View Post
If it's inside the PHP code you should use something like:

echo '<b>this is html';
So:

echo '<b>this is html';
<html>
<etc. etc. etc.>
</html> ?

paste anywhere within the script?

edmltw is offline   Reply With Quote
Old 11-16-2009, 08:03 AM   #5
Edmund Lee
War Room Member
 
edmltw's Avatar
 
Join Date: Jul 2009
Location: Singapore
Posts: 624
Blog Entries: 2
Thanks: 124
Thanked 91 Times in 57 Posts
Social Networking View Member's Myspace Profile  View Member's YouTube Profile
Contact Info
Send a message via Skype™ to edmltw
Default Re: PHP Issue: How Do I insert raw HTML into .PHP scripts?

Quote:
Originally Posted by chaos69 View Post
Alternatively, and this may be the safer option for you, if you do not want to break the php tags you can simply do the following in a suitable location.

print <<<GACODE

paste your GA code in here

GACODE;


If the index.php has a footer section, this would be an ideal location, just before the closing </html> tag.
Woah.. Pardon me for my ignorance, but what's a GACODE? MY bad..

Ed

edmltw is offline   Reply With Quote
Old 11-16-2009, 08:07 AM   #6
HyperActive Warrior
War Room Member
 
Join Date: May 2009
Location: U.K
Posts: 197
Thanks: 5
Thanked 39 Times in 36 Posts
Social Networking View Member's Twitter Profile 
Default Re: PHP Issue: How Do I insert raw HTML into .PHP scripts?

EDIT: Changed.
You simply need to paste your Google Analytics code inside the print statement.

print <<<GACODE

paste your Google Analytics Code in here. or any HTML for that matter.

GACODE;

Best Ways To Make Money Online

Eight bytes walk into a bar. The bartender asks, “Can I get you anything?”
“Yeah,” reply the bytes. “Make us a double.”
Luke Graham is offline   Reply With Quote
Old 11-16-2009, 08:24 AM   #7
Edmund Lee
War Room Member
 
edmltw's Avatar
 
Join Date: Jul 2009
Location: Singapore
Posts: 624
Blog Entries: 2
Thanks: 124
Thanked 91 Times in 57 Posts
Social Networking View Member's Myspace Profile  View Member's YouTube Profile
Contact Info
Send a message via Skype™ to edmltw
Default Re: PHP Issue: How Do I insert raw HTML into .PHP scripts?

For example:

......require($template->get_template_dir('main_template_vars.php',DIR_WS_ TEMPLATE, $current_page_base,'common'). '/main_template_vars.php');
/**
* Read the "on_load" scripts for the individual page, and from the site-wide template settings
* NOTE: on_load_*.js files must contain just the raw code to be inserted in the <body> tag in the on_load="" parameter.
* Looking in "/includes/modules/pages" for files named "on_load_*.js"
*/
$directory_array = $template->get_template_part(DIR_WS_MODULES . 'pages/' . $current_page_base, '/^on_load_/', '.js');
foreach ($directory_array as $value) {
$onload_file = DIR_WS_MODULES . 'pages/' . $current_page_base . '/' . $value;
$read_contents='';
$lines = @file($onload_file);
foreach($lines as $line) {
$read_contents .= $line;
}
$za_onload_array[] = $read_contents;
}
* print <<<GACODE
<script EXAMPLE EXAMPLE EXAMPLE
</script>


......

Like that above? Thanks..

Ed

Quote:
Originally Posted by chaos69 View Post
EDIT: Changed.
You simply need to paste your Google Analytics code inside the print statement.

print <<<GACODE

paste your Google Analytics Code in here. or any HTML for that matter.

GACODE;

edmltw is offline   Reply With Quote
Old 11-16-2009, 08:32 AM   #8
HyperActive Warrior
War Room Member
 
Join Date: May 2009
Location: U.K
Posts: 197
Thanks: 5
Thanked 39 Times in 36 Posts
Social Networking View Member's Twitter Profile 
Default Re: PHP Issue: How Do I insert raw HTML into .PHP scripts?

Quote:
Originally Posted by edmltw View Post
* print <<<GACODE
<script EXAMPLE EXAMPLE EXAMPLE
</script>


......

Like that above? Thanks..
You will need to include the closing tag as well;

print <<<GACODE
<script EXAMPLE EXAMPLE EXAMPLE
</script>
GACODE;


( However - i thought analytics usually went towards the end of the page, I.E before </body> or </html> - i'm not sure if it matters where you put it since i don't use it )

Best Ways To Make Money Online

Eight bytes walk into a bar. The bartender asks, “Can I get you anything?”
“Yeah,” reply the bytes. “Make us a double.”
Luke Graham is offline   Reply With Quote
Old 11-17-2009, 03:08 AM   #9
HyperActive Warrior
War Room Member
 
gordi555's Avatar
 
Join Date: Nov 2009
Posts: 168
Thanks: 7
Thanked 10 Times in 10 Posts
Default Re: PHP Issue: How Do I insert raw HTML into .PHP scripts?

Think people have their own way of doing this and might be confusing.

Send the file to me, tell me exactly where you'd like it and I'll send it back with code inserted.

Don't thank me, just give me money (joke)
gordi555 is offline   Reply With Quote
Reply

  WarriorForum - Internet Marketing Forums > Warrior Support Forums > Programming Talk

Tags
html, insert, issue, php, raw, scripts

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT -6. The time now is 07:49 AM.