how to use anycontent.php how to use anycontent.php
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

how to use anycontent.php

Started by brynn, October 15, 2013, 11:32:41 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

brynn

Hi Friends,
After some research (searching forum and manual) I haven't found very much helpful info about how to use the anycontent.php feature.  So besides getting answers for myself, maybe this topic will help others too.  Perhaps for someone who knows php, it's very clear how to use it.  But for me, not so much.

When you read the manual section for the anycontent.php feature, it says you need to know php to use it.  But in another topic where I made a new feature request for front page content, Andre answered this:

Quote from: ΑndrĂ© on September 28, 2013, 12:56:14 PM
Just add your HTML code to the anycontent.php file. ...

So it sounds like I might be able to use it, since I do know some basic html.  But exactly where to put the html is not clear to me.  The example in the manual, and the actual anycontent.php file are entirely different (except for the <?php at the beginning, and ?> at the end).  So I assume that the example in the manual displays an entirely different page (or section of a page) than the anycontent.php file.  And of course I realize that the default anycontent.php file is not meant to be used as it is.  But just as a user experience comment, it might be helpful if the example in the manual looks something like the actual default anycontent page (i.e. with the copyright, version, and license info included)  ;)  Anyway, since the example in the manual does not use html, I can't really use it as a guide....unless I actually want to display a message to guests, I guess.

In perusing the actual default anycontent.php file, the only recognizable html is between

echo <<< EOT

and

EOT;

which I assume is where the html code should go, as Andre suggested.  Correct?

And it looks like the entire html content needs to go inside the css "tableb" class' cell (<td>).  Is that correct?  I guess the tableb class is what makes it look like part of the theme?

Could I make several cells (<td>)?  What if I made another row (<tr>)?  Or could I replace everything between the EOTs?  Like for example, could I use a div element instead of tr?  Or could I put an entire table, inside <table> tags?  I guess it is entirely possible to have an entire table inside a <td> element.  So maybe these questions are moot?  I guess if I replace the <tr> tags, I lose the tableb styling, right?

I'm actually not sure exactly how I want to use the anycontent feature.  What I am sure about is that I want to get rid of the Random section.  My first idea is just to display the same 2 or 3 images, all the time.  If my gallery becomes very popular, I may want to use it for a Featured Images or Featured Artist section, which would change periodically.  So far, the gallery hasn't caught on yet, so I'm very limited in what to display there.  But let's start with the idea of having 2 images displayed in this new section (or maybe it's called a block?).

Do I write the html using <img> tags?  What do I put for the URL, to have the thumbnail show up?  If I can make the thumbnail show up, would I need to make the images to be active links to the intermediate page (<a href=url>)?  Or is the thumbnail automatically a link?

Just above the starting EOT it says:

starttable("100%", $lang_index_php['welcome']);

Does that mean it displays the word "welcome" in whatever language the user uses?  So for example, where it says "Random files" in the attached image -- is that where "Welcome" will show up, in this new section/block?  If that's the case, then I might want to change it, to something like "Featured images".  Or is 'welcome' just part of the code, and doesn't get displayed?

Thanks for you help and patience with all my newbie-ness  :o

Niecher


brynn

Thanks Niecher.  Perhaps there is an issue with how you understand my message, because of the translation (from Spanish, I think)?  The problem is not that I don't know how to write html, in general.  The problem is not understanding how CPG/anycontent.php uses html.

The manual says that the admin needs to have an understanding of php, to be able to use anycontent.php.  However, in the quote from Andre, he seems to indicate that it might not be necessary to know how to write php, and that  html can be inserted into the php file.  So that's what I'm investigating.

Hhmmm....rather than trying to re-phrase all my questions, maybe it would be better to wait for someone else to reply?  I'm not sure.  If no one else has answered after a day or 2, I will re-phrase all my questions, and ask them again.

Meanwhile.....well.....based on a LOT of assumptions, maybe I'll take a stab at editing the anycontent.php file.  Then maybe I could specifically illustrate my questions for you.

Thanks again  :)

brynn

Ok, I have a very simple, but somewhat successful, anycontent.php file working:  http://inkscapecommunity.com/ic_gallery/index.php

Now to repeat the still unanswered questions.

1 -- The titlebar (for lack of proper teminology) for the anycontent block says "Welcome!".  I thought if I changed

starttable("100%", $lang_index_php['welcome']);

to

starttable("100%", $lang_index_php['Featured Image']);

it would cause "Featured Image" to appear in the titlebar area.  That didn't work, and instead "Welcome!" just disappeared.  But then I noticed that the anycontent.php file said "welcome", yet "Welcome!" was displayed.  So I thought if I tried changing

starttable("100%", $lang_index_php['Featured Image']);

to

starttable("100%", $lang_index_php['featured image']);

it might work.  But it didn't  :(  So it seems like I can have either "Welcome!" or nothing -- unless someone can tell me how to display "Featured Image" in that sort of titlebar location? 

So Question #1 -- How can I change the currently displayed  "Welcome!" to whatever I might need?  Also, in the future, I may make this a monthly feature, or a featured artist, or maybe even featured album (if I could figure out how to put an album in the <td> tags)   .  So if there is any way to change it, it would need to be something that I can change as needed.  If that can't be changed, hhmmm....well, maybe I could put the text inside the block, instead of in the titlebar area?

2 -- Centering the image.  I tried a few different ways to center the image in the block.  In the end, I had to use <div align=center> even though, unless I'm misunderstanding what I've read at the W3Schools site, <div align=center> is deprecated code.

I also tried centering using margin property but I couldn't make it work.  I actually was able to center the image by putting it in <th> tags, but that seemed somewhat inappropriate.

But I also read that affecting a layout using tables is not the correct use of the table element (on this page).  At least not anymore.  So perhaps CPG hasn't caught up to the standards yet?  (Note that I don't mean to sound critical.  I'm really fairly well overwhelmed with all of this, and trying hard to understand.)  So perhaps using <div align=center> is the proper way to do it, after all?

So Question #2 -- Is there a better way to center a single image?  Another thing I might like to do, is have 2 featured images shown there.  But I can't seem to sort out how to have 2 images centered.  I couldn't get margin:auto to work, but maybe a % value would work?  Or maybe I could find a way to use div align=center for that too?

And let me be clear.  I realize that you probably don't want to provide support for html code.  But since I could only center the image by using an outdated code, I'm not sure if I can depend on W3Schools to provide what I need for CPG.  On the other hand, there's every chance that I still haven't found the proper way to do it yet. 

So without stepping outside your comfort zone, if you could give me just a hint about these things, I would be very grateful  :)

Thank you very much for whatever help you can offer  :)

Jeff Bailey

#4
 in lang/english.php

// ------------------------------------------------------------------------- //
// File index.php
// ------------------------------------------------------------------------- //
if (defined('INDEX_PHP')){
$lang_index_php['welcome'] = 'Welcome!';

Change the text in the language files, of course this only changes it for the languages you choose to change.

I'm a little fuzzy on what images are you trying to center exactly?

edit: Not sure if you noticed but you have the theme selector enabled.
Thinking is the hardest work there is, which is probably the reason why so few engage in it. - Henry Ford

Niecher

Hello brynn,

To put any title, you can use this:

starttable("100%", "Featured Image");


and to put two images and center them without <div>, you can use this:

    <tr>
       <td class="tableb" align="center">
         <img src="http://inkscapecommunity.com/ic_gallery/albums/userpics/10009/1.png" alt="featured image" />
         <img src="http://inkscapecommunity.com/ic_gallery/albums/userpics/10009/2.png" alt="featured image" />
       </td>
    </tr>


Regards.

brynn

Ah-HA!

I thought of td align=center, too, Niecher, but it's also said to be deprecated.  So I thought somehow using div would make it less so, somehow  ::)

Jeff Bailey, there's only 1 image there now.  But I may (probably) want to have 2.  Yes, I enabled the theme selector on purpose.  And I enabled it for all the themes I'm using, so members can switch back and forth, if they like.  :)  (Most members will be artistic, or at least creative, and may be more likely to have particular tastes regarding the theme (than most people).  So that's why I wanted to have a few themes available.)

Regarding changing the "Welcome!" text in the top bar of the anycontent block -- I understand both of your suggestions.  I'm just not sure which one would be best to use.  I do have the gallery set up for a number of different languages, and hope to have some international membership.  So perhaps it would be best to use Jeff Bailey's suggestion?  Although Niecher's suggestion would be much easier, if doing it that way, will allow the text will be translated.

Hhmmm....ok, so when I change the code which Jeff Bailey indicated, for example in spanish.php, I'll have to actually look up the translation of "Featured Images" or "Featured Artist" (or whatever I decide to use) in spanish, to put the proper text in spanish.php file.  Right?  I'm guessing this will be the best way to do it.

Ok, than you both very much!

phill104

If using multi languages please use the option detailed by Jeff.
It is a mistake to think you can solve any major problems just with potatoes.

brynn

Ok, I gave it my best shot, lol.  Using Bing and Google translators can be an adventure, so I can only wait for feedback from members, if I got it wrong.

For now, my questions are answered.  But I may become more adventurous in the future, with the anycontent block.  So I'll mard solved for now, but may open again in the future.

Thank you very much, to everyone who helped  :)