Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #9726

Re: can one make a php function or macro with arguments to generate HTML code?

From Jerry Stuckle <jstucklex@attglobal.net>
Newsgroups comp.lang.php
Subject Re: can one make a php function or macro with arguments to generate HTML code?
Date 2013-06-01 09:10 -0400
Organization A noiseless patient Spider
Message-ID <kocrjr$j5c$1@dont-email.me> (permalink)
References <129060de-f94d-4853-ab35-0246d9cc2e35@2g2000yqr.googlegroups.com>

Show all headers | View raw


On 6/1/2013 6:21 AM, steve nospam wrote:
> I am newbie. I am writing HTML and find myself duplicating lots of
> code, which is the same except for 1 or 2 names/items in it.
>
> I do not know how to make a function or macro that takes arguments in
> HTML or CSS. Then I read that php is much more powerful and one should
> code HTML pages in php.
>
> Here is an example of what I have, I am just asking for a hint or a
> link on how to code this in php.
>
>    <div class="blabla">
>       <video poster="folder_name/image.png" controls>
>               <source src="folder_name/movie.ogv" type="video/ogg">
>               <source src="folder_name/movie.mp4" type="video/mp4">
>               opps, browser does not support the video tag.
>       </video>
>    </div>
>
> The above block of HTML close is repeated many time. Each time, a
> different "folder_name" is used.
> So I end up copy/paste and edit this code many many times.
>
> It would be nice if I can define a function, and just pass it the
> folder_name and it returns back this whole code. So the above becomes
>
>    <div class="name">
>       make_video_code("ABC")
>    </div>
>
>    <div class="name">
>       make_video_code("ADR")
>    </div>
>
>    <div class="name">
>       make_video_code("ACB")
>    </div>
>
> etc.... you get the idea.
>
> Is something like this possible? Does any one have a templates or
> example of how to do this in php? where to put the function
> make_video_code()?
>
> thanks
> Steve
>

Steve,

Yes, when working with HTML, there is a lot of duplication of HTML and 
CSS.  That's how things are.

As Luuk said, you can do it in PHP.  But in reality, how much are you 
going to save?  You'll have to copy/paste the PHP code instead of the 
HTML, and your code (which is basically static).

Maybe a better solution would be to use an editor which support macros.

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

can one make a php function or macro with arguments to generate HTML code? steve nospam <steve.nospamm@gmail.com> - 2013-06-01 03:21 -0700
  Re: can one make a php function or macro with arguments to generate HTML code? Luuk <luuk@invalid.lan> - 2013-06-01 12:42 +0200
    Re: can one make a php function or macro with arguments to generate HTML code? Luuk <luuk@invalid.lan> - 2013-06-01 12:57 +0200
  Re: can one make a php function or macro with arguments to generate HTML code? Jerry Stuckle <jstucklex@attglobal.net> - 2013-06-01 09:10 -0400
    Re: can one make a php function or macro with arguments to generate HTML code? steve nospam <steve.nospamm@gmail.com> - 2013-06-01 06:23 -0700
      Re: can one make a php function or macro with arguments to generate HTML code? Jerry Stuckle <jstucklex@attglobal.net> - 2013-06-01 10:16 -0400
  Re: can one make a php function or macro with arguments to generate HTML code? Twayne <nobody@spamcop.net> - 2013-06-01 10:22 -0400

csiph-web