Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

"InnerHTML" in PHP?

LEGEND ,
Apr 18, 2006 Apr 18, 2006
How would I use PHP to copy the filename into the alt attribute? For
example,

<img
src="a-really-long-filename-that-I-also-want-to-use-without-hyphens.jpg"
alt="<?php echo("WHATTHEHECKGOESHERE?"); ?>">

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================



TOPICS
Server side applications
2.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 18, 2006 Apr 18, 2006
> How would I use PHP to copy the filename into the alt attribute? For
> example,
>
> <img
> src="a-really-long-filename-that-I-also-want-to-use-without-hyphens.jpg"
> alt="<?php echo("WHATTHEHECKGOESHERE?"); ?>">

Why would you want the filename in the alt attribute?

If you did, though, PHP being server side, you'd just serve the SRC and ALT
attribute the same string variable.

-Darrel


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 18, 2006 Apr 18, 2006
echo '<img src="' . $filename . '" alt="' . $filename . '"/>';
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 18, 2006 Apr 18, 2006
Nope. I don't have a $filename variable. It would have to be read from the
DOM which means I have to use js.

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"VVebbie" <webforumsuser@macromedia.com> wrote in message
news:e23jbs$8v0$1@forums.macromedia.com...
> echo '<img src="' . $filename . '" alt="' . $filename . '"/>';


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 18, 2006 Apr 18, 2006

"Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
news:e23kh7$a5r$1@forums.macromedia.com...
> Nope. I don't have a $filename variable. It would have to be read from
> the DOM which means I have to use js.


If you use JS, they won't be visible to search engines and they won't
validate.


--
--
Tom Muck
co-author Dreamweaver MX 2004: The Complete Reference
http://www.tom-muck.com/

Cartweaver Development Team
http://www.cartweaver.com

Extending Knowledge Daily
http://www.communitymx.com/


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 18, 2006 Apr 18, 2006
That is true. Dang.

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"Tom Muck" <tommuck@NOSPAM.basic-drumbeat.com> wrote in message
news:e23mte$d72$1@forums.macromedia.com...
>
> "Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
> news:e23kh7$a5r$1@forums.macromedia.com...
>> Nope. I don't have a $filename variable. It would have to be read from
>> the DOM which means I have to use js.
>
>
> If you use JS, they won't be visible to search engines and they won't
> validate.
>
>
> --
> --
> Tom Muck
> co-author Dreamweaver MX 2004: The Complete Reference
> http://www.tom-muck.com/
>
> Cartweaver Development Team
> http://www.cartweaver.com
>
> Extending Knowledge Daily
> http://www.communitymx.com/
>
>


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 18, 2006 Apr 18, 2006
> That is true. Dang.

Maybe give us the big picture here...what's your ultimate goal?

-Darrel


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 19, 2006 Apr 19, 2006
.oO(Darrel)

>Maybe give us the big picture here...what's your ultimate goal?

World domination, but I'm already working on that.

Micha
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 19, 2006 Apr 19, 2006
On 19 Apr 2006 in macromedia.dreamweaver.appdev, Michael Fesser wrote:

> .oO(Darrel)
>
>>Maybe give us the big picture here...what's your ultimate goal?
>
> World domination, but I'm already working on that.

Make sure you write the app in .Net/C#.

--
Joe Makowiec
http://makowiec.net/
Email: http://makowiec.net/email.php
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 19, 2006 Apr 19, 2006
<uhh> Great suggestion! 8)

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"Joe Makowiec" <makowiec@invalid.invalid> wrote in message
news:Xns97AA3D55FA2AAmakowiecatnycapdotrE@216.104.212.96...
> On 19 Apr 2006 in macromedia.dreamweaver.appdev, Michael Fesser wrote:
>
>> .oO(Darrel)
>>
>>>Maybe give us the big picture here...what's your ultimate goal?
>>
>> World domination, but I'm already working on that.
>
> Make sure you write the app in .Net/C#.
>
> --
> Joe Makowiec
> http://makowiec.net/
> Email: http://makowiec.net/email.php


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 19, 2006 Apr 19, 2006
See my reply to Massimo for the 'big pix' words! 8)

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"Darrel" <notreal@nospam.com> wrote in message
news:e243n0$rh4$1@forums.macromedia.com...
>> That is true. Dang.
>
> Maybe give us the big picture here...what's your ultimate goal?
>
> -Darrel
>


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 19, 2006 Apr 19, 2006

"Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
news:e254re$7qc$1@forums.macromedia.com...
> See my reply to Massimo for the 'big pix' words! 8)
>
> --

The part where I'm getting lost is that you said this was a static page. If
the page is static, then you already know the filename, which means you
already know the caption. Why wouldn't one of the in-Dreamweaver solutions
provided earlier work?


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 18, 2006 Apr 18, 2006
It's a static page!

Hmm - I think I will have to do it with javascript. I have a page with a
bunch of images on it. I want to snoop out each src attribute's value,
strip the dashes out, and place the resulting string into the alt attribute.

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"darrel" <notreal@nowhere.com> wrote in message
news:e23d0d$11p$1@forums.macromedia.com...
>> How would I use PHP to copy the filename into the alt attribute? For
>> example,
>>
>> <img
>> src="a-really-long-filename-that-I-also-want-to-use-without-hyphens.jpg"
>> alt="<?php echo("WHATTHEHECKGOESHERE?"); ?>">
>
> Why would you want the filename in the alt attribute?
>
> If you did, though, PHP being server side, you'd just serve the SRC and
> ALT attribute the same string variable.
>
> -Darrel
>


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 18, 2006 Apr 18, 2006

> It's a static page!
>
> Hmm - I think I will have to do it with javascript.

If it's a static page, then you'd HAVE to use javascript...as PHP only
executes server-side.

> I have a page with a bunch of images on it. I want to snoop out each src
> attribute's value, strip the dashes out, and place the resulting string
> into the alt attribute.

Yes, javascript would work.

I imagine the logic would be to:

- find all IMG objects on page and set to an array.
- loop through the array grabbing each img's SRC
- parse the string
- replace value of alt with new string

Alas, you'll have to wait for one of the javascript experts to actually show
you how to do that ;o)

Again, though, a filename isn't terribly useful in the alt attribute in most
cases.

-Darrel


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 18, 2006 Apr 18, 2006
"Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
news:e23j2o$8fb$1@forums.macromedia.com...
> Hmm - I think I will have to do it with javascript. I have a page with a
> bunch of images on it. I want to snoop out each src attribute's value,
> strip the dashes out, and place the resulting string into the alt
> attribute.

I attached a DW's query you can use. It doesn't strip the dashes out, but
adds an alt attribute, with its value being equal to the src attribute. It's
a quick and dirty solution, so please be careful, backup first and test it.
Keep in mind it assumes the alt attribute is totally missing.

Hope it could help

BTW I hope other forum users don't mind the attachment...


--
----------------------------
Massimo Foti
Tools for ColdFusion and Dreamweaver developers:
http://www.massimocorner.com
----------------------------


begin 666 murray.dwr
M/#]X;6P@=F5R<VEO;CTB,2XP(C\^#0H\9'=Q=65R>3X-"B @/'%U97)Y<&%R
M86US(&UA=&-H8V%S93TB=')U92(@:6=N;W)E=VAI=&5S<&%C93TB9F%L<V4B
M('5S97)E9V5X<#TB=')U92)W:&]L97=O<F0](F9A;'-E(B\^#0H@(#QF:6YD
M/@T*(" @(#QQ=&5X="!Q;F%M93TB*"9L=#MI;6=;7B9G=#M=*BES<F,])G%U
M;W0[*"XJ*29Q=6]T.RA;7B9G=#M=*B9G=#LI(B!Q<F%W/2)T<G5E(CX\+W%T
M97AT/@T*(" \+V9I;F0^#0H@(#QR97!L86-E(&%C=&EO;CTB<F5P;&%C951E
M>'0B('!A<F%M,3TB)#%S<F,])G%U;W0[)#(F<75O=#L@86QT/29Q=6]T.R0R
D)G%U;W0[("0S(B!P87)A;3(](B(O/@T*/"]D=W%U97)Y/@T*
`
end

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 18, 2006 Apr 18, 2006
> If it's a static page, then you'd HAVE to use javascript...as PHP only
> executes server-side.

I was first thinking that I could use the PHP to determine the value of the
src attribute for that particular image. But I realized on reflection that
that would come from the DOM.

> Again, though, a filename isn't terribly useful in the alt attribute in
> most cases.

I have my reasons! 8)

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"darrel" <notreal@nowhere.com> wrote in message
news:e23jap$8pg$1@forums.macromedia.com...
>
>> It's a static page!
>>
>> Hmm - I think I will have to do it with javascript.
>
> If it's a static page, then you'd HAVE to use javascript...as PHP only
> executes server-side.
>
>> I have a page with a bunch of images on it. I want to snoop out each src
>> attribute's value, strip the dashes out, and place the resulting string
>> into the alt attribute.
>
> Yes, javascript would work.
>
> I imagine the logic would be to:
>
> - find all IMG objects on page and set to an array.
> - loop through the array grabbing each img's SRC
> - parse the string
> - replace value of alt with new string
>
> Alas, you'll have to wait for one of the javascript experts to actually
> show you how to do that ;o)
>
> Again, though, a filename isn't terribly useful in the alt attribute in
> most cases.
>
> -Darrel
>


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 18, 2006 Apr 18, 2006
Massimo:

Thanks bud! What I really need, though, is something that will do this when
the page loads, not inside of DW. And I need it to strip the dashes when it
does.

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"Massimo Foti" <massimo@massimocorner.com> wrote in message
news:e23kbr$a0h$1@forums.macromedia.com...
> "Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
> news:e23j2o$8fb$1@forums.macromedia.com...
>> Hmm - I think I will have to do it with javascript. I have a page with a
>> bunch of images on it. I want to snoop out each src attribute's value,
>> strip the dashes out, and place the resulting string into the alt
>> attribute.
>
> I attached a DW's query you can use. It doesn't strip the dashes out, but
> adds an alt attribute, with its value being equal to the src attribute.
> It's a quick and dirty solution, so please be careful, backup first and
> test it. Keep in mind it assumes the alt attribute is totally missing.
>
> Hope it could help
>
> BTW I hope other forum users don't mind the attachment...
>
>
> --
> ----------------------------
> Massimo Foti
> Tools for ColdFusion and Dreamweaver developers:
> http://www.massimocorner.com
> ----------------------------
>
>
>


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 18, 2006 Apr 18, 2006
"Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
news:e23kjr$adb$1@forums.macromedia.com...
> Thanks bud! What I really need, though, is something that will do this
> when the page loads, not inside of DW. And I need it to strip the dashes
> when it does.

I see! try this out:

<script type="text/javascript">
function loadAlt(){
var imgNodes = document.getElementsByTagName("img");
for(var i=0; i<imgNodes.length; i++){
var cleanedSrc = imgNodes .src.replace("-", "");
imgNodes
.setAttribute("alt", cleanedSrc);
}
}
</script>
</head>
<body onload="loadAlt()">

Hope it will help, it's late here and I am ready to go to bed :-)

Massimo


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 18, 2006 Apr 18, 2006
Massimo Foti wrote:
> I see! try this out:
>
> <script type="text/javascript">
> function loadAlt(){
> var imgNodes = document.getElementsByTagName("img");
> for(var i=0; i<imgNodes.length; i++){
> var cleanedSrc = imgNodes .src.replace("-", "");
> imgNodes
.setAttribute("alt", cleanedSrc);
> }
> }
> </script>
> </head>
> <body onload="loadAlt()">

That would definitely do what Murray wants, but it would apply to all
images on a page. It also relies on JavaScript being enabled. So, to
remain valid, you would need to set a default alt attribute.

I suspect that Murray probably needs something that works using
getElementById, rather than getElementsByTagName. Alternatively, you
might need getElementsByTagName combined with getAttribute('class') to
whip through those images that are set to a particular class.

--
David Powers
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "Foundation PHP 5 for Flash" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 18, 2006 Apr 18, 2006
"David Powers" <david@example.com> wrote in message
news:e23n2q$dc7$1@forums.macromedia.com...
> That would definitely do what Murray wants, but it would apply to all
> images on a page.

Muray wrote: "I want to snoop out each src attribute's value"



> It also relies on JavaScript being enabled.

That's the nature of JavaScript :-)



> So, to remain valid, you would need to set a default alt attribute.

I usually don't care about valdity, but sounds like a good suggestion


--
----------------------------
Massimo Foti
Tools for ColdFusion and Dreamweaver developers:
http://www.massimocorner.com
----------------------------


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 19, 2006 Apr 19, 2006
.oO(Massimo Foti)

>"David Powers" <david@example.com> wrote in message
>news:e23n2q$dc7$1@forums.macromedia.com...
>
>> It also relies on JavaScript being enabled.
>
>That's the nature of JavaScript :-)

alert('Please enable JavaScript to view this site!');

Micha
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 19, 2006 Apr 19, 2006
That's in all my pages now! 8)

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"Michael Fesser" <netizen@gmx.de> wrote in message
news:noub42h6og0uqo3bkv6hcs858rece9vlrj@4ax.com...
> .oO(Massimo Foti)
>
>>"David Powers" <david@example.com> wrote in message
>>news:e23n2q$dc7$1@forums.macromedia.com...
>>
>>> It also relies on JavaScript being enabled.
>>
>>That's the nature of JavaScript :-)
>
> alert('Please enable JavaScript to view this site!');
>
> Micha


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 19, 2006 Apr 19, 2006
.oO(Murray *ACE*)

>That's in all my pages now! 8)

I've already seen such code "in the wild" ...

Micha
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 19, 2006 Apr 19, 2006
Thanks, Massimo.

Here's the deal: I'm making a photo gallery for my brother. He has
hundreds, nay thousands, of images taken all over the world (as a
professional wildlife photographer). He gives me the images with names as I
indicated earlier (words and keywords separated by hyphens).

I am using an app that can display the alt attribute's value as a photo
caption. This would be why I am asking these goofy questions - to
automatically transfer the filename to the alt attribute, and to strip out
the hyphens. But I think a stake has been driven through this one's heart
by the comment that dynamically written content like that is not 'on the
page'. So - I'm back to the drawing board.

What's that you say? Why don't I use a database? That would, of course, be
the obvious solution. But his data is not in a form that lends itself to
that approach at this moment! 8(

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"Massimo Foti" <massimo@massimocorner.com> wrote in message
news:e23lb2$b7r$1@forums.macromedia.com...
> "Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
> news:e23kjr$adb$1@forums.macromedia.com...
>> Thanks bud! What I really need, though, is something that will do this
>> when the page loads, not inside of DW. And I need it to strip the dashes
>> when it does.
>
> I see! try this out:
>
> <script type="text/javascript">
> function loadAlt(){
> var imgNodes = document.getElementsByTagName("img");
> for(var i=0; i<imgNodes.length; i++){
> var cleanedSrc = imgNodes .src.replace("-", "");
> imgNodes
.setAttribute("alt", cleanedSrc);
> }
> }
> </script>
> </head>
> <body onload="loadAlt()">
>
> Hope it will help, it's late here and I am ready to go to bed :-)
>
> Massimo
>


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 19, 2006 Apr 19, 2006
.oO(Murray *ACE*)

>I am using an app that can display the alt attribute's value as a photo
>caption. This would be why I am asking these goofy questions - to
>automatically transfer the filename to the alt attribute, and to strip out
>the hyphens.

Wouldn't that lead to captions like
"areallylongfilenamethatIalsowanttousewithouthyphens"? What's the
purpose of that?

> But I think a stake has been driven through this one's heart
>by the comment that dynamically written content like that is not 'on the
>page'. So - I'm back to the drawing board.

Everything like this should be done on the server.

>What's that you say? Why don't I use a database?

Would be helpful for storing the captions and maybe additional
informations about each picture (keywords, date etc.)

>That would, of course, be
>the obvious solution. But his data is not in a form that lends itself to
>that approach at this moment! 8(

I would still probably go the DB-route and use the filename as a first,
initial caption. It allows to easily modify the captions to a more
reasonable and more descriptive text at a later time.

Micha
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines