SlideShare uma empresa Scribd logo
1 de 35
PHP for HTML Gurus
Andrea Tarr
Tarr Consulting
J and Beyond 2012
Outline
• PHP Basics
• Explanation of
  actual code in
  templates &




                     Beyond 2012 • Andrea Tarr
                     PHP for HTML Gurus • J and
  layouts
• Changing code
  and seeing it in
  action
• Book give away
                                2
PHP Basics
• Get in and out of PHP with <?php ?>
• End each statement with a semi-colon
<?php
      $first_name = 'Andrea';




                                                  Beyond 2012 • Andrea Tarr
                                                  PHP for HTML Gurus • J and
      $last_name = 'Tarr';
?>

• Whitespace is irrelevant
<?php $first_name='Andrea';$last_name='Tarr';?>


• Omit any final ?> at the end of a file                     3
Comments
• Single line comments
// This is a single line comment
$language = 'PHP'; // End of line comment
// Multiple lines of single comments




                                            Beyond 2012 • Andrea Tarr
                                            PHP for HTML Gurus • J and
// can be done by repeating the slashes

• Multiple line comments
/* With this type of comment you can
start a comment on one line and end
it on an other line */
                                                       4
Variables
•   Used to store information that can change
•   Start with a $
•   Assign a value with =
•   Use single ('') or double ("") quotes for text




                                                      Beyond 2012 • Andrea Tarr
                                                      PHP for HTML Gurus • J and
• You need to assign a value before you can use the
  variable
• Use echo to display a value
• Use a dot (.) to join items together

$first_name = 'Andrea';
$last_name = 'Tarr';                                             5
echo $first_name . ' ' . $last_name;
$Variable Types
•   String Text: Andrea
•   Numbers: 42
•   Logical: True/False, 1/0
•   Array: An array is a list, either indexed or named




                                                         Beyond 2012 • Andrea Tarr
                                                         PHP for HTML Gurus • J and
    • [0]=>Sun, [1]=>Mon, [2]=>Tue, [3]=>Wed
    • Name=>Joomla, Version=>2.5,
    • You can nest arrays
• Object: We'll come back to Object shortly



                                                                    6
Functions()
• Functions perform an action
• You recognize a function by the ()
• You can pass information to the function in the ()
$full_name = '       Andrea             Tarr       ';
echo trim($full_name);




                                                        Beyond 2012 • Andrea Tarr
                                                        PHP for HTML Gurus • J and
• This results in Andrea Tarr

• You can pass a function to a function
echo strtoupper(trim($full_name);

• This results in ANDREA TARR                                      7
CONSTANTS
• Constants are assigned once and don't change
• No $
• Usually in ALL CAPS
define('SITENAME', 'My Site');




                                                 Beyond 2012 • Andrea Tarr
                                                 PHP for HTML Gurus • J and
echo SITENAME;




                                                            8
Objects
• Think of an object as a named array plus functions
• Properties are variables
• Functions are also called methods




                                                       Beyond 2012 • Andrea Tarr
                                                       PHP for HTML Gurus • J and
Examples:
• $item->title contains the title
• $item->introtext contains the intro text
• $params->get('show_modify_date')



                                                                  9
Classes
• Classes are the blueprints that are used to create
  objects
• You can use the classes directly without creating an
  object




                                                         Beyond 2012 • Andrea Tarr
                                                         PHP for HTML Gurus • J and
Examples:
• JText::_('COM_CONTENT_READ_MORE');
• JHtml::_('string.truncate', ($this->item->title),
  $params->get('readmore_limit'))


                                                               10
Making Decisions: if/else
• Example 1
if ($sum > 10) :
      // do something when greater than 10
else :
      // do something when 10 or less




                                              Beyond 2012 • Andrea Tarr
                                              PHP for HTML Gurus • J and
endif;

• Example 2
if ($errors) :
      // do something when there are errors
endif;
                                                    11
• You can also nest if statements
Comparison Operators




Don't use = to compare!




                          PHP for HTML Gurus • J and
12




                          Beyond 2012 • Andrea Tarr
One Line If Statement
• Normal way
if ($gender == 'M') :
     echo 'Man';
else :




                                           Beyond 2012 • Andrea Tarr
                                           PHP for HTML Gurus • J and
     echo 'Woman';
endif;

• One line version
echo ($gender == 'M') ? 'Man' : 'Woman';

                                                 13
Alternative Syntax
• Alternative Syntax used when mixing with HTML
if ($sum > 10) :
       // do something when greater than 10
else :
       // do something when 10 or less




                                                  Beyond 2012 • Andrea Tarr
                                                  PHP for HTML Gurus • J and
endif;

• Normal syntax with curly braces
if ($sum > 10) {
      // do something when greater than 10
} else {
      // do something when 10 or less                   14
}
Looping
• While
  • Repeats while a condition is true
• Do/While
  • Does it at least once then repeats while true
• For




                                                       Beyond 2012 • Andrea Tarr
                                                       PHP for HTML Gurus • J and
  • Loops a given number of times
• Foreach
  • Repeats the code for each element in an array or
    object
• Jumping out early
  • Continue
        • Jump to the next iteration
  • Break                                                    15
        • Jump out of the loop
Template index.php file
•   Template Parameters
•   Conditional Stylesheets
•   Conditional Positions
•   One Line If Statement




                              Beyond 2012 • Andrea Tarr
                              PHP for HTML Gurus • J and
                                    16
Template Parameters
$color = $this->params->get('templatecolor');

<link rel="stylesheet" href="<?php echo
$this->baseurl ?>/templates/<?php echo




                                                       Beyond 2012 • Andrea Tarr
                                                       PHP for HTML Gurus • J and
$this->template; ?>/css/<?php echo
 htmlspecialchars($color); ?>.css"
type="text/css" />

<link rel="stylesheet"
href="/localhost/jc/templates/beez_20/css/personal.c
ss" type="text/css" />                                       17
Conditional Stylesheets
<?php if ($this->direction == 'rtl') : ?>
 <link rel="stylesheet" href="<?php echo
 $this->baseurl ?>/templates/<?php echo
 $this->template; ?>/css/template_rtl.css"




                                             Beyond 2012 • Andrea Tarr
                                             PHP for HTML Gurus • J and
 type="text/css" />
<?php endif; ?>




                                                   18
Conditional Positions
<?php if ($this->countModules('position-12')): ?>
<div id="top">
 <jdoc:include type="modules" name="position-12" />
</div>




                                                      Beyond 2012 • Andrea Tarr
                                                      PHP for HTML Gurus • J and
<?php endif; ?>




                                                            19
One Line If Statement
$showRightColumn =
($this->countModules('position-3') OR
$this->countModules('position-6') OR
$this->countModules('position-8'));




                                                      Beyond 2012 • Andrea Tarr
                                                      PHP for HTML Gurus • J and
<div id="<?php echo
 $showRightColumn ? 'contentarea2' : 'contentarea';
?>">

If there are right modules: <div id="contentarea2">
If there aren't: <div id="contentarea">                     20
Module Layout
• Latest Articles
• mod_articles_latest/tmpl/default.php




                                         Beyond 2012 • Andrea Tarr
                                         PHP for HTML Gurus • J and
                                               21
Latest Articles




     PHP for HTML Gurus • J and
22




     Beyond 2012 • Andrea Tarr
Latest News default.php




     PHP for HTML Gurus • J and
23




     Beyond 2012 • Andrea Tarr
var_dump()




     PHP for HTML Gurus • J and
24




     Beyond 2012 • Andrea Tarr
Object $item




     PHP for HTML Gurus • J and
25




     Beyond 2012 • Andrea Tarr
Object $item




     PHP for HTML Gurus • J and
26




     Beyond 2012 • Andrea Tarr
Object $item – Page 2




     PHP for HTML Gurus • J and
27




     Beyond 2012 • Andrea Tarr
Object $item – Page 3




     PHP for HTML Gurus • J and
28




     Beyond 2012 • Andrea Tarr
Object $item – Page 4




     PHP for HTML Gurus • J and
29




     Beyond 2012 • Andrea Tarr
Object $item – Page 5




     PHP for HTML Gurus • J and
30




     Beyond 2012 • Andrea Tarr
Object $item – Page 6




     PHP for HTML Gurus • J and
31




     Beyond 2012 • Andrea Tarr
Add information




     PHP for HTML Gurus • J and
32




     Beyond 2012 • Andrea Tarr
List with intro text




     PHP for HTML Gurus • J and
33




     Beyond 2012 • Andrea Tarr
Questions?




     PHP for HTML Gurus • J and
34




     Beyond 2012 • Andrea Tarr
Book Give Away




     PHP for HTML Gurus • J and
35




     Beyond 2012 • Andrea Tarr

Mais conteúdo relacionado

Mais procurados

Regular expression unit2
Regular expression unit2Regular expression unit2
Regular expression unit2smitha273566
 
OOP - Introduction to Inheritance
OOP - Introduction to InheritanceOOP - Introduction to Inheritance
OOP - Introduction to InheritanceMohammad Shaker
 
Advance java session 14
Advance java session 14Advance java session 14
Advance java session 14Smita B Kumar
 
Intro to Object Oriented Programming with Java
Intro to Object Oriented Programming with Java Intro to Object Oriented Programming with Java
Intro to Object Oriented Programming with Java Hitesh-Java
 
Developer testing 101: Become a Testing Fanatic
Developer testing 101: Become a Testing FanaticDeveloper testing 101: Become a Testing Fanatic
Developer testing 101: Become a Testing FanaticLB Denker
 
introduction to javascript
introduction to javascriptintroduction to javascript
introduction to javascriptKumar
 

Mais procurados (12)

Regular expression unit2
Regular expression unit2Regular expression unit2
Regular expression unit2
 
OOP - Introduction to Inheritance
OOP - Introduction to InheritanceOOP - Introduction to Inheritance
OOP - Introduction to Inheritance
 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentals
 
Java script
Java scriptJava script
Java script
 
Advance java session 14
Advance java session 14Advance java session 14
Advance java session 14
 
Intro to Object Oriented Programming with Java
Intro to Object Oriented Programming with Java Intro to Object Oriented Programming with Java
Intro to Object Oriented Programming with Java
 
Developer testing 101: Become a Testing Fanatic
Developer testing 101: Become a Testing FanaticDeveloper testing 101: Become a Testing Fanatic
Developer testing 101: Become a Testing Fanatic
 
Materi Dasar PHP
Materi Dasar PHPMateri Dasar PHP
Materi Dasar PHP
 
introduction to javascript
introduction to javascriptintroduction to javascript
introduction to javascript
 
Php Tutorial
Php TutorialPhp Tutorial
Php Tutorial
 
Ravi software faculty
Ravi software facultyRavi software faculty
Ravi software faculty
 
Os Borger
Os BorgerOs Borger
Os Borger
 

Destaque

Memphis php html form processing with php
Memphis php   html form processing with phpMemphis php   html form processing with php
Memphis php html form processing with phpJoe Ferguson
 
Chapter 02 php basic syntax
Chapter 02   php basic syntaxChapter 02   php basic syntax
Chapter 02 php basic syntaxDhani Ahmad
 
Arrays &amp; functions in php
Arrays &amp; functions in phpArrays &amp; functions in php
Arrays &amp; functions in phpAshish Chamoli
 
How To Build A Bulk Email Sending Application In PHP
How To Build A Bulk Email Sending Application In PHPHow To Build A Bulk Email Sending Application In PHP
How To Build A Bulk Email Sending Application In PHPSudheer Satyanarayana
 

Destaque (7)

PHP Tutorials
PHP TutorialsPHP Tutorials
PHP Tutorials
 
Memphis php html form processing with php
Memphis php   html form processing with phpMemphis php   html form processing with php
Memphis php html form processing with php
 
Chapter 02 php basic syntax
Chapter 02   php basic syntaxChapter 02   php basic syntax
Chapter 02 php basic syntax
 
Arrays &amp; functions in php
Arrays &amp; functions in phpArrays &amp; functions in php
Arrays &amp; functions in php
 
How To Build A Bulk Email Sending Application In PHP
How To Build A Bulk Email Sending Application In PHPHow To Build A Bulk Email Sending Application In PHP
How To Build A Bulk Email Sending Application In PHP
 
Php Presentation
Php PresentationPhp Presentation
Php Presentation
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 

Semelhante a PHP for HTML Gurus - J and Beyond 2012

Standard Coding, OOP Techniques and Code Reuse
Standard Coding, OOP Techniques and Code ReuseStandard Coding, OOP Techniques and Code Reuse
Standard Coding, OOP Techniques and Code ReuseRayhan Chowdhury
 
Object Relational Mapping in PHP
Object Relational Mapping in PHPObject Relational Mapping in PHP
Object Relational Mapping in PHPRob Knight
 
PHP complete reference with database concepts for beginners
PHP complete reference with database concepts for beginnersPHP complete reference with database concepts for beginners
PHP complete reference with database concepts for beginnersMohammed Mushtaq Ahmed
 
PHP 5.4 New Features
PHP 5.4 New FeaturesPHP 5.4 New Features
PHP 5.4 New FeaturesHaim Michael
 
PHP Variables & Comments 01
PHP Variables & Comments 01PHP Variables & Comments 01
PHP Variables & Comments 01Spy Seat
 
Synapseindia reviews sharing intro cakephp
Synapseindia reviews sharing intro cakephpSynapseindia reviews sharing intro cakephp
Synapseindia reviews sharing intro cakephpSynapseindiaComplaints
 
What's new in PHP 7.1
What's new in PHP 7.1What's new in PHP 7.1
What's new in PHP 7.1Simon Jones
 
TAKING PHP SERIOUSLY - Keith Adams
TAKING PHP SERIOUSLY - Keith AdamsTAKING PHP SERIOUSLY - Keith Adams
TAKING PHP SERIOUSLY - Keith AdamsHermes Alves
 
PSR-7 - Middleware - Zend Expressive
PSR-7 - Middleware - Zend ExpressivePSR-7 - Middleware - Zend Expressive
PSR-7 - Middleware - Zend ExpressiveMilad Arabi
 
TDD with PhpSpec - Lone Star PHP 2016
TDD with PhpSpec - Lone Star PHP 2016TDD with PhpSpec - Lone Star PHP 2016
TDD with PhpSpec - Lone Star PHP 2016CiaranMcNulty
 
Class 2 - Introduction to PHP
Class 2 - Introduction to PHPClass 2 - Introduction to PHP
Class 2 - Introduction to PHPAhmed Swilam
 
PHP 8: Process & Fixing Insanity
PHP 8: Process & Fixing InsanityPHP 8: Process & Fixing Insanity
PHP 8: Process & Fixing InsanityGeorgePeterBanyard
 
HackU PHP and Node.js
HackU PHP and Node.jsHackU PHP and Node.js
HackU PHP and Node.jssouridatta
 
DIG1108C Lesson3 Fall 2014
DIG1108C Lesson3 Fall 2014DIG1108C Lesson3 Fall 2014
DIG1108C Lesson3 Fall 2014David Wolfpaw
 
Drupal 8: A story of growing up and getting off the island
Drupal 8: A story of growing up and getting off the islandDrupal 8: A story of growing up and getting off the island
Drupal 8: A story of growing up and getting off the islandAngela Byron
 
php Chapter 1.pptx
php Chapter 1.pptxphp Chapter 1.pptx
php Chapter 1.pptxHambaAbebe2
 

Semelhante a PHP for HTML Gurus - J and Beyond 2012 (20)

Standard Coding, OOP Techniques and Code Reuse
Standard Coding, OOP Techniques and Code ReuseStandard Coding, OOP Techniques and Code Reuse
Standard Coding, OOP Techniques and Code Reuse
 
Object Relational Mapping in PHP
Object Relational Mapping in PHPObject Relational Mapping in PHP
Object Relational Mapping in PHP
 
PHP complete reference with database concepts for beginners
PHP complete reference with database concepts for beginnersPHP complete reference with database concepts for beginners
PHP complete reference with database concepts for beginners
 
Current state-of-php
Current state-of-phpCurrent state-of-php
Current state-of-php
 
PHP 5.4 New Features
PHP 5.4 New FeaturesPHP 5.4 New Features
PHP 5.4 New Features
 
PHP Variables & Comments 01
PHP Variables & Comments 01PHP Variables & Comments 01
PHP Variables & Comments 01
 
TDD with PhpSpec
TDD with PhpSpecTDD with PhpSpec
TDD with PhpSpec
 
Synapseindia reviews sharing intro cakephp
Synapseindia reviews sharing intro cakephpSynapseindia reviews sharing intro cakephp
Synapseindia reviews sharing intro cakephp
 
What's new in PHP 7.1
What's new in PHP 7.1What's new in PHP 7.1
What's new in PHP 7.1
 
TAKING PHP SERIOUSLY - Keith Adams
TAKING PHP SERIOUSLY - Keith AdamsTAKING PHP SERIOUSLY - Keith Adams
TAKING PHP SERIOUSLY - Keith Adams
 
PSR-7 - Middleware - Zend Expressive
PSR-7 - Middleware - Zend ExpressivePSR-7 - Middleware - Zend Expressive
PSR-7 - Middleware - Zend Expressive
 
TDD with PhpSpec - Lone Star PHP 2016
TDD with PhpSpec - Lone Star PHP 2016TDD with PhpSpec - Lone Star PHP 2016
TDD with PhpSpec - Lone Star PHP 2016
 
Class 2 - Introduction to PHP
Class 2 - Introduction to PHPClass 2 - Introduction to PHP
Class 2 - Introduction to PHP
 
PHP 8: Process & Fixing Insanity
PHP 8: Process & Fixing InsanityPHP 8: Process & Fixing Insanity
PHP 8: Process & Fixing Insanity
 
Welcome to hack
Welcome to hackWelcome to hack
Welcome to hack
 
HackU PHP and Node.js
HackU PHP and Node.jsHackU PHP and Node.js
HackU PHP and Node.js
 
DIG1108C Lesson3 Fall 2014
DIG1108C Lesson3 Fall 2014DIG1108C Lesson3 Fall 2014
DIG1108C Lesson3 Fall 2014
 
Drupal 8: A story of growing up and getting off the island
Drupal 8: A story of growing up and getting off the islandDrupal 8: A story of growing up and getting off the island
Drupal 8: A story of growing up and getting off the island
 
php Chapter 1.pptx
php Chapter 1.pptxphp Chapter 1.pptx
php Chapter 1.pptx
 
Hardcore PHP
Hardcore PHPHardcore PHP
Hardcore PHP
 

Mais de Andrea Tarr

Using LESS, the CSS Preprocessor: J and Beyond 2013
Using LESS, the CSS Preprocessor: J and Beyond 2013Using LESS, the CSS Preprocessor: J and Beyond 2013
Using LESS, the CSS Preprocessor: J and Beyond 2013Andrea Tarr
 
The State of Joomla - J and Beyond 2013
The State of Joomla - J and Beyond 2013The State of Joomla - J and Beyond 2013
The State of Joomla - J and Beyond 2013Andrea Tarr
 
LESS, the CSS Preprocessor
LESS, the CSS PreprocessorLESS, the CSS Preprocessor
LESS, the CSS PreprocessorAndrea Tarr
 
Bootstrap & Joomla UI
Bootstrap & Joomla UIBootstrap & Joomla UI
Bootstrap & Joomla UIAndrea Tarr
 
Bootstrap for Extension Developers JWC 2012
Bootstrap for Extension Developers  JWC 2012Bootstrap for Extension Developers  JWC 2012
Bootstrap for Extension Developers JWC 2012Andrea Tarr
 
Bootstrap Introduction
Bootstrap IntroductionBootstrap Introduction
Bootstrap IntroductionAndrea Tarr
 
Where is Joomla going and how do we get there? J and Beyond 2012
Where is Joomla going and how do we get there? J and Beyond 2012Where is Joomla going and how do we get there? J and Beyond 2012
Where is Joomla going and how do we get there? J and Beyond 2012Andrea Tarr
 
Choosing Great Joomla Extensions
Choosing Great Joomla ExtensionsChoosing Great Joomla Extensions
Choosing Great Joomla ExtensionsAndrea Tarr
 

Mais de Andrea Tarr (8)

Using LESS, the CSS Preprocessor: J and Beyond 2013
Using LESS, the CSS Preprocessor: J and Beyond 2013Using LESS, the CSS Preprocessor: J and Beyond 2013
Using LESS, the CSS Preprocessor: J and Beyond 2013
 
The State of Joomla - J and Beyond 2013
The State of Joomla - J and Beyond 2013The State of Joomla - J and Beyond 2013
The State of Joomla - J and Beyond 2013
 
LESS, the CSS Preprocessor
LESS, the CSS PreprocessorLESS, the CSS Preprocessor
LESS, the CSS Preprocessor
 
Bootstrap & Joomla UI
Bootstrap & Joomla UIBootstrap & Joomla UI
Bootstrap & Joomla UI
 
Bootstrap for Extension Developers JWC 2012
Bootstrap for Extension Developers  JWC 2012Bootstrap for Extension Developers  JWC 2012
Bootstrap for Extension Developers JWC 2012
 
Bootstrap Introduction
Bootstrap IntroductionBootstrap Introduction
Bootstrap Introduction
 
Where is Joomla going and how do we get there? J and Beyond 2012
Where is Joomla going and how do we get there? J and Beyond 2012Where is Joomla going and how do we get there? J and Beyond 2012
Where is Joomla going and how do we get there? J and Beyond 2012
 
Choosing Great Joomla Extensions
Choosing Great Joomla ExtensionsChoosing Great Joomla Extensions
Choosing Great Joomla Extensions
 

Último

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 

Último (20)

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 

PHP for HTML Gurus - J and Beyond 2012

  • 1. PHP for HTML Gurus Andrea Tarr Tarr Consulting J and Beyond 2012
  • 2. Outline • PHP Basics • Explanation of actual code in templates & Beyond 2012 • Andrea Tarr PHP for HTML Gurus • J and layouts • Changing code and seeing it in action • Book give away 2
  • 3. PHP Basics • Get in and out of PHP with <?php ?> • End each statement with a semi-colon <?php $first_name = 'Andrea'; Beyond 2012 • Andrea Tarr PHP for HTML Gurus • J and $last_name = 'Tarr'; ?> • Whitespace is irrelevant <?php $first_name='Andrea';$last_name='Tarr';?> • Omit any final ?> at the end of a file 3
  • 4. Comments • Single line comments // This is a single line comment $language = 'PHP'; // End of line comment // Multiple lines of single comments Beyond 2012 • Andrea Tarr PHP for HTML Gurus • J and // can be done by repeating the slashes • Multiple line comments /* With this type of comment you can start a comment on one line and end it on an other line */ 4
  • 5. Variables • Used to store information that can change • Start with a $ • Assign a value with = • Use single ('') or double ("") quotes for text Beyond 2012 • Andrea Tarr PHP for HTML Gurus • J and • You need to assign a value before you can use the variable • Use echo to display a value • Use a dot (.) to join items together $first_name = 'Andrea'; $last_name = 'Tarr'; 5 echo $first_name . ' ' . $last_name;
  • 6. $Variable Types • String Text: Andrea • Numbers: 42 • Logical: True/False, 1/0 • Array: An array is a list, either indexed or named Beyond 2012 • Andrea Tarr PHP for HTML Gurus • J and • [0]=>Sun, [1]=>Mon, [2]=>Tue, [3]=>Wed • Name=>Joomla, Version=>2.5, • You can nest arrays • Object: We'll come back to Object shortly 6
  • 7. Functions() • Functions perform an action • You recognize a function by the () • You can pass information to the function in the () $full_name = ' Andrea Tarr '; echo trim($full_name); Beyond 2012 • Andrea Tarr PHP for HTML Gurus • J and • This results in Andrea Tarr • You can pass a function to a function echo strtoupper(trim($full_name); • This results in ANDREA TARR 7
  • 8. CONSTANTS • Constants are assigned once and don't change • No $ • Usually in ALL CAPS define('SITENAME', 'My Site'); Beyond 2012 • Andrea Tarr PHP for HTML Gurus • J and echo SITENAME; 8
  • 9. Objects • Think of an object as a named array plus functions • Properties are variables • Functions are also called methods Beyond 2012 • Andrea Tarr PHP for HTML Gurus • J and Examples: • $item->title contains the title • $item->introtext contains the intro text • $params->get('show_modify_date') 9
  • 10. Classes • Classes are the blueprints that are used to create objects • You can use the classes directly without creating an object Beyond 2012 • Andrea Tarr PHP for HTML Gurus • J and Examples: • JText::_('COM_CONTENT_READ_MORE'); • JHtml::_('string.truncate', ($this->item->title), $params->get('readmore_limit')) 10
  • 11. Making Decisions: if/else • Example 1 if ($sum > 10) : // do something when greater than 10 else : // do something when 10 or less Beyond 2012 • Andrea Tarr PHP for HTML Gurus • J and endif; • Example 2 if ($errors) : // do something when there are errors endif; 11 • You can also nest if statements
  • 12. Comparison Operators Don't use = to compare! PHP for HTML Gurus • J and 12 Beyond 2012 • Andrea Tarr
  • 13. One Line If Statement • Normal way if ($gender == 'M') : echo 'Man'; else : Beyond 2012 • Andrea Tarr PHP for HTML Gurus • J and echo 'Woman'; endif; • One line version echo ($gender == 'M') ? 'Man' : 'Woman'; 13
  • 14. Alternative Syntax • Alternative Syntax used when mixing with HTML if ($sum > 10) : // do something when greater than 10 else : // do something when 10 or less Beyond 2012 • Andrea Tarr PHP for HTML Gurus • J and endif; • Normal syntax with curly braces if ($sum > 10) { // do something when greater than 10 } else { // do something when 10 or less 14 }
  • 15. Looping • While • Repeats while a condition is true • Do/While • Does it at least once then repeats while true • For Beyond 2012 • Andrea Tarr PHP for HTML Gurus • J and • Loops a given number of times • Foreach • Repeats the code for each element in an array or object • Jumping out early • Continue • Jump to the next iteration • Break 15 • Jump out of the loop
  • 16. Template index.php file • Template Parameters • Conditional Stylesheets • Conditional Positions • One Line If Statement Beyond 2012 • Andrea Tarr PHP for HTML Gurus • J and 16
  • 17. Template Parameters $color = $this->params->get('templatecolor'); <link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/<?php echo Beyond 2012 • Andrea Tarr PHP for HTML Gurus • J and $this->template; ?>/css/<?php echo htmlspecialchars($color); ?>.css" type="text/css" /> <link rel="stylesheet" href="/localhost/jc/templates/beez_20/css/personal.c ss" type="text/css" /> 17
  • 18. Conditional Stylesheets <?php if ($this->direction == 'rtl') : ?> <link rel="stylesheet" href="<?php echo $this->baseurl ?>/templates/<?php echo $this->template; ?>/css/template_rtl.css" Beyond 2012 • Andrea Tarr PHP for HTML Gurus • J and type="text/css" /> <?php endif; ?> 18
  • 19. Conditional Positions <?php if ($this->countModules('position-12')): ?> <div id="top"> <jdoc:include type="modules" name="position-12" /> </div> Beyond 2012 • Andrea Tarr PHP for HTML Gurus • J and <?php endif; ?> 19
  • 20. One Line If Statement $showRightColumn = ($this->countModules('position-3') OR $this->countModules('position-6') OR $this->countModules('position-8')); Beyond 2012 • Andrea Tarr PHP for HTML Gurus • J and <div id="<?php echo $showRightColumn ? 'contentarea2' : 'contentarea'; ?>"> If there are right modules: <div id="contentarea2"> If there aren't: <div id="contentarea"> 20
  • 21. Module Layout • Latest Articles • mod_articles_latest/tmpl/default.php Beyond 2012 • Andrea Tarr PHP for HTML Gurus • J and 21
  • 22. Latest Articles PHP for HTML Gurus • J and 22 Beyond 2012 • Andrea Tarr
  • 23. Latest News default.php PHP for HTML Gurus • J and 23 Beyond 2012 • Andrea Tarr
  • 24. var_dump() PHP for HTML Gurus • J and 24 Beyond 2012 • Andrea Tarr
  • 25. Object $item PHP for HTML Gurus • J and 25 Beyond 2012 • Andrea Tarr
  • 26. Object $item PHP for HTML Gurus • J and 26 Beyond 2012 • Andrea Tarr
  • 27. Object $item – Page 2 PHP for HTML Gurus • J and 27 Beyond 2012 • Andrea Tarr
  • 28. Object $item – Page 3 PHP for HTML Gurus • J and 28 Beyond 2012 • Andrea Tarr
  • 29. Object $item – Page 4 PHP for HTML Gurus • J and 29 Beyond 2012 • Andrea Tarr
  • 30. Object $item – Page 5 PHP for HTML Gurus • J and 30 Beyond 2012 • Andrea Tarr
  • 31. Object $item – Page 6 PHP for HTML Gurus • J and 31 Beyond 2012 • Andrea Tarr
  • 32. Add information PHP for HTML Gurus • J and 32 Beyond 2012 • Andrea Tarr
  • 33. List with intro text PHP for HTML Gurus • J and 33 Beyond 2012 • Andrea Tarr
  • 34. Questions? PHP for HTML Gurus • J and 34 Beyond 2012 • Andrea Tarr
  • 35. Book Give Away PHP for HTML Gurus • J and 35 Beyond 2012 • Andrea Tarr

Notas do Editor

  1. Introduction to meIntro to the course. This isn&apos;t meant to teach you how to write PHP from scratch. It&apos;s meant to make you more comfortable around the php you come across in templates and layouts.Who can copy/paste PHP statements in templates and layouts? Who can make minor changes to PHP? Who can write PHP? Anyone here who is new to both HTML and PHP?
  2. I&apos;m going to start by going through the basics of how PHP works. This is going to go fairly fast and don&apos;t expect to remember all of it. It will make more sense when we start looking at the actual code, but it helps if you understand a bit of the basics first.So once we finish that, we will look at (what exactly are the files?)Then we&apos;ll try changing something in the code (adding a missing field, like the intro to something that is only title?) and see it working in actiion
  3. The nouns $color css files
  4. functions are the verb
  5. $this = JDocumentHTML
  6. This is the layout file that outputs the list of latest articles. This is the file that you would copy to your template to override with your changes
  7. $list is aAdd a var_dump to see what&apos;s there that we want to use