How to use image tags or variables in a news story.

Discuss news styles, css code, and other Coranto customizations in here...the possibilities are endless, so have at it!

Moderator: Spunkmeyer

Postby Esstee » Fri Jun 17, 2005 5:38 pm

okay.

so can I change $img1 for [img1]?
or does it absolutely need the $ in front of it ?
I went deeper into the belly of Coranto and look! I found maginot.
User avatar
Esstee
 
Posts: 320
Joined: Thu Nov 25, 2004 4:13 pm
Location: Deep in some project

Postby Lumberjack » Fri Jun 17, 2005 5:53 pm

Basically think of it like this... the variable is actually called $img1. In Perl, if you want to know whats in it etc, you would refer to it as $img1. In coranto styles, you can also use the alias <Field: img1>, or if you prefer you can call it via perlcode tags like I just specified (which is longer to write though).
$img1 = <Field: img1>
$myvar = <Field: myvar>
You see? Perl also has other symbols for things, like @array and %hash but lets not get technical.
[img1] will neither work in perl or coranto (unless you are using anne rice to replace it).
Lumberjack
 
Posts: 555
Joined: Wed Jan 10, 2007 7:22 pm
Location: Oxford, UK

Postby Esstee » Fri Jun 17, 2005 6:10 pm

Parahead drew up this code some time ago for someone else
I was not able to use it because it was calling out my full http url and
producing authentication errors on my site...

but recently I had the idea to use an internal path for my multipart image
fields and so this is what I get now (which is good)

The magic code:

Code: Select all
<PerlCode>
$MP_FieldName = "CustomField_Text_image1";
$Text =~ s!\[img1\]!'<IMG SRC="' . $fieldDB{$MP_FieldName}->{http} . '/' . ${$MP_FieldName} . '">'!ge;
</PerlCode>


The tag to use in my article is [img1]

the output for [img1] in my published article is:
Code: Select all
<IMG SRC="/imgdata/news/article_images/conic.gif">


is this good?
you darned right it is! because with these tags and the quicktag addon
I can create simple [img1] [img2] [img3] and so on... buttons to
place wherever I want in my article..

AND... to make things evern sweeter, when I return to edit the document
I always have [img] tags to manipulate so its not all messy :D

Anyways I have not tied everything up just yet but I think this will do the
trick, if so I can finally move ahead with my project.

I'll post the results here shortly
I went deeper into the belly of Coranto and look! I found maginot.
User avatar
Esstee
 
Posts: 320
Joined: Thu Nov 25, 2004 4:13 pm
Location: Deep in some project

Postby Parahead » Fri Jun 17, 2005 6:19 pm

Esstee wrote:is this good?
you darned right it is! because with these tags and the quicktag addon
I can create simple [img1] [img2] [img3] and so on... buttons to
place wherever I want in my article..

AND... to make things evern sweeter, when I return to edit the document
I always have [img] tags to manipulate so its not all messy :D
Actually I started to play around with a little addon that basically is very similar to Anne Rice but it does the substitution on the fly (I was playing around with calling the addon Flying Rice). It would do the very same substitution thing you do above, but you define this substitute in an Anne Rice approach, that is on a page of it's own. The reason for creating the addon is just as you mention, Anne Rice has a tendensy of messing up things at the Edit News page...
Yes, I am still around...
www.parahead.com/coranto/
User avatar
Parahead
 
Posts: 4837
Joined: Fri Jan 12, 2007 8:54 pm
Location: Stockholm - Sweden

Postby Esstee » Fri Jun 17, 2005 6:52 pm

I was playing around with calling the addon Flying Rice


Parahead thats halarious!

and... that addon would freakin' awesome seriously, the code above works
but when I edit the article it is rendered back into HTML but hey... who's
complaining I'm just happy to of gotten over this massive stumbling block.

it feels like someone just removed a large wooden spike from my side 8)
I went deeper into the belly of Coranto and look! I found maginot.
User avatar
Esstee
 
Posts: 320
Joined: Thu Nov 25, 2004 4:13 pm
Location: Deep in some project

Postby Esstee » Fri Jun 17, 2005 9:40 pm

I wanted to ask something in regards to this code:

Code: Select all
<PerlCode>
$MP_FieldName = "CustomField_Text_image1";
$Text =~ s!\[img1\]!'<IMG SRC="' . $fieldDB{$MP_FieldName}->{http} . '/' . ${$MP_FieldName} . '">'!ge;
</PerlCode>


I have to create a snippet of code for every [img#] tag I am using so I was
wondering if there was a way for one instance of this code to work with any
[img] tag?

the tags are always according to the field no.
ex:

[img1] = CustomField_Text_image1
[img2] = CustomField_Text_image2
[img3] = CustomField_Text_image3
...

So is there a way to make the code fit the given tags if they are present
in the document? This was just an idea I had when I was creating the code
for 6 fields and I thought I could create a popup with quicklinks to prompt
the user for a number upon clicking the image button insertion.

Something like a [Place IMG] button that would prompt for the following:

image no. (default 1)
Alignement (default left)

Could produce an output like [img1_LF]
I went deeper into the belly of Coranto and look! I found maginot.
User avatar
Esstee
 
Posts: 320
Joined: Thu Nov 25, 2004 4:13 pm
Location: Deep in some project

Postby Parahead » Sat Jun 18, 2005 11:07 am

You could use this snippet:
Code: Select all
<PerlCode>
$MP_FieldName = "CustomField_Text_image";
$Text =~ s!\[img(\d+) align=([^\]]+)\]!'<IMG SRC="' . $fieldDB{"$MP_FieldName$1"}->{http} . '/' . ${"$MP_FieldName$1"} . '" align="$2">'!ge;
</PerlCode>
Which would allow you to add a number to the img tag, and place an alignment attribute, like this:
Code: Select all
[img1 align=left]
[img2 align=center]
Code not tested, so it may contain bugs though...
Yes, I am still around...
www.parahead.com/coranto/
User avatar
Parahead
 
Posts: 4837
Joined: Fri Jan 12, 2007 8:54 pm
Location: Stockholm - Sweden

Postby shanemckiness » Sat Jun 18, 2005 8:04 pm

Estee. What is your URL? I would love to see where all this is going. I use maginot heavily too.


Shane
shanemckiness
 
Posts: 234
Joined: Fri May 21, 2004 5:14 pm

Postby Esstee » Sat Jun 18, 2005 11:30 pm

thank you Parahead

I have been pretty much off the project due to the flu, so I'm not really
into things right now.

I did play with your code a bit it looks really kool and the img# option seems
to work perfectly! as for the alignement I'm not sure if its working or not
heres what I put in my news story to test things:

Code: Select all
[b]Title:[/b] Image placement tag test no. 3

[b]Text:[/b]
[img1 align=left]
asd asd asd asd a


my result was this:

Code: Select all
<a name="newsitemEEEAEFylAZACGbJsXW"></a>
Image placement tag test no. 3
<IMG SRC="/imgdata/news/article_images/conic.gif" align="$2">
<br><br>asd asd asd asd a


So the way I did it, it looks like it managed the image alignement
again I may have missconfigured it i donno...
I went deeper into the belly of Coranto and look! I found maginot.
User avatar
Esstee
 
Posts: 320
Joined: Thu Nov 25, 2004 4:13 pm
Location: Deep in some project

Postby Lumberjack » Sun Jun 19, 2005 1:45 am

I think its something like this for the start of the substitution:
Code: Select all
s!\[img(\d+) align=(\w+)\]!

If you wanted to make the align bit optional you could probably do this by putting brackets around that part and a question mark afterwards:
Code: Select all
s!\[img(\d+)( align=(\w+))?\]!

But I think then you put have to use $3 for the alignment.
Lumberjack
 
Posts: 555
Joined: Wed Jan 10, 2007 7:22 pm
Location: Oxford, UK

Postby Esstee » Sun Jun 19, 2005 4:10 am

you mean I have to setup $1 $2 and $3 variables for my alignment code?
:)


* Esstee added later...


No matter I only need to write three block now instead of 24 to get things
working, I don't think its worth pressing on ol' Parahead for more of his time
on this matter. He's done enough :)

I'll get it done using what is there, its more than good imo.

Thanks LJ also.
I went deeper into the belly of Coranto and look! I found maginot.
User avatar
Esstee
 
Posts: 320
Joined: Thu Nov 25, 2004 4:13 pm
Location: Deep in some project

Postby Parahead » Sun Jun 19, 2005 6:47 am

Try this one out, will work...
Code: Select all
<PerlCode>
$MP_FieldName = "CustomField_Text_image";
$Text =~ s!\[img(\d+)( align=([^\]]+))?\]!'<IMG SRC="' . $fieldDB{"$MP_FieldName$1"}->{http} . '/' . ${"$MP_FieldName$1"} . '"' . ($2?qq~ align="$3">~:'>')!ge;
</PerlCode>
I have also implemented so that the alignment is optional, thus you can use both [img1] and [img1 align=center]
Yes, I am still around...
www.parahead.com/coranto/
User avatar
Parahead
 
Posts: 4837
Joined: Fri Jan 12, 2007 8:54 pm
Location: Stockholm - Sweden

Postby Esstee » Sun Jun 19, 2005 3:25 pm

Parahead I just tested your code, once again your ideas save me a
ton of writing!

This will work perfectly, I haven't decided if I will use CSS or plain img
alignement tags to get the job done I still have to do a bit of research on the
benefits of each but with this code I can get the entire thing wirtten in this one
bit of code :D

I'm still pretty down with the flu so I won't be back in the spirit of things until
monday I think.

Great work and thank you for your continued support If you weren't here I think
I would of given up a long time ago.
I went deeper into the belly of Coranto and look! I found maginot.
User avatar
Esstee
 
Posts: 320
Joined: Thu Nov 25, 2004 4:13 pm
Location: Deep in some project

Postby Esstee » Sun Jun 19, 2005 3:59 pm

I tried to add something to your code but I was unsuccessful in doing so.
I would like to learn eventually.

anyways this was my idea, I use a captions, normally I use a quicklink button
to add the CSS around the img tag but then I started thinking, it would be
even better to add the caption along with the image selection in the submission
screen as shown bellow:

Image

By using a dynamic table the presence of caption determines the proper
formating so without leaving basic html if it were possible to add another
piece of code to your IMG tag solution everything could exist in one block.

the caption fields are as follows <Field: CustomField_img_caption#>
So do you think this can be added in the code? it doesnt matter where it is
in the line atm. I can move it around to fit the html formating myself but
I just can't figure out how to add a new section into it :) I tried but it
wouldn't even allow me to save the style lol

let me know if you think this can be done, otherwise I will keep the existing
quicklink tags.
I went deeper into the belly of Coranto and look! I found maginot.
User avatar
Esstee
 
Posts: 320
Joined: Thu Nov 25, 2004 4:13 pm
Location: Deep in some project

Postby Esstee » Sun Jun 19, 2005 5:04 pm

Success!

Code: Select all
<PerlCode>
$MP_FieldName1 = "CustomField_Text_image";
$MP_FieldName2 = "CustomField_img_caption";
$Text =~ s!\[img(\d+)( align=([^\]]+))?\]!'<IMG SRC="' . $fieldDB{"$MP_FieldName1$1"}->{http} . '/' . ${"$MP_FieldName1$1"} . '"' . ($2?qq~ align="$3">~:'>'). ${"$MP_FieldName2$1"}!ge;
</PerlCode>


I have not tested it very much it seems to work so far, still unformated this
model might be able to work :D
I went deeper into the belly of Coranto and look! I found maginot.
User avatar
Esstee
 
Posts: 320
Joined: Thu Nov 25, 2004 4:13 pm
Location: Deep in some project

Previous

Return to Customization

Who is online

Users browsing this forum: No registered users and 2 guests

cron