Jump to content

Fieldtype Image: some questions...


doolak
 Share

Recommended Posts

Hello there,

for a current project it would be necessary to add some pictures which are shown on the homepage slider. First i thought i just have to do it similar to the PW example homepage - but i need one textarea to be added to each picture...

How can this bis solved? I just have the idea of the following solutions:

1. Writing a new fildtype which has such a texarea

2. Use an extra page and template for those pictures - but here i would have the possibility to choose just one image and i just discovered that it seem not to be possible to restrict the upload to just one image - dont know if i am right or i just missed something...

Any other idea?

Kind regards,

Christian

Link to comment
Share on other sites

Hi doolak;

- if textfield (not textarea) is sufficient for your needs, your image fieldtype might have those – this should cover your basic 'slogan' needs, but obviously, having to edit HTML or longer/structured text in this input[text] would not be ideal

- imagefield SHOULD be limitable by maximum number of images, that might be uploaded; it's somewhere in the field settings. If you've found it, but it doesn't respond (it isn't editable, doesn't save value, etc.) it's a bug.

Adam

Link to comment
Share on other sites

Hello Adam,

imagefield SHOULD be limitable by maximum number of images

Yes, thats right - i just did not see that... Thank you for your help.

if textfield (not textarea) is sufficient for your needs, your image fieldtype might have those

You are talking about the "Description", right? Would be a possibility for a short slogan, yes - but i need some more text, so a textarea would be better.

So if i want to setup my own set of fields, i have to use a page and a template to assemble them, right? Or build a special fieldtype module... That's a pity - because it would be so nice to have the images listed like its done in the PW example page.

Repeatable regions would be the solution - maybe a feature for future releases...

Link to comment
Share on other sites

Posting from mobile, so this will be short. You can easily get the same listing with multiple pages & single image than with single page & multiple images. Even the php-code in your templates will be pretty close.

Link to comment
Share on other sites

Hello apeisa,

thanks for your answer!

Yes, i guess this will be the only possibility as long as repeatable regions are not supported - technically should be no problem, like you said: the PHP code will be almost the same. Just would have been if those images could be simply added to the homepage by editing "Home".

I am no figuring out how i can sort pages in the page tree the best to have such page-specific feature shown up as child of the related page - something like this would be nice:

Root

  - Home

      - Slider Images

  - About

  - Gallery

      - Gallery 1

      - Gallery 2

      - Gallery 3

  - Contact

That would make it little more structured for the editor, because he can see that the images belong to the homepage.

Right now i am checking out if its possible to set such a "Root" page which is not shown as frontpage...

     

Link to comment
Share on other sites

Yes, that could be a good option - that "Root" - thing seems to be not very good idea...

Maybe one time there will be repeatable regions in which one can collect some fields - that would be a very nice addition.

---

As i saw now there is a fieldtype called "Fieldset" - i just tried it out now and i ask myself if this couldn't be a good starting point and if it will be possible to make it repeatable.

Link to comment
Share on other sites

Repeatable fieldgroupd are planned, though we can't say sure for which version.

I just realized, that there sshould be option to set different number of descriptions, would number like 2 or 3 sufficient? You could use some metacode like this:

<?php foreach($page->sliderImages as $sliderImage): ?>
  <div>
    <img src="<?php echo $sliderImage->url;?>" ... />
    <h2><?php echo $sliderImage->description[0]; ?></h2>
    <p><?php echo $sliderImage->description[1]; ?></p>
<?php endforeach; ?>

Note: your HTML might be different. you might introduce also 'if field exists, then echo, otherwise not' code. And also, I have never used description for images myself, so correct code might be different.

Link to comment
Share on other sites

Hm, that doesnt work for me - there is still one "Description" field shown when i edit the page.

Here's my code:

<?php
                  	    foreach($page->images as $image) {	
                  		$large = $image->width(261, 157);
                  		echo "<li>";
                  		echo "<div class='inner-banner'>";
                  		echo "<div class='screen'>";
                  		echo "<img src='{$large->url}' alt='' />"; ?>
                  		<h2><?php echo $large->description[0]; ?></h2>
                  		<p><?php echo $large->description[1]}; ?></p>
                  		echo "</div>";
                  		echo "</div>";
                  		echo "</li>";
                  	}
                  ?>
Link to comment
Share on other sites

Well i guess the best for such cases is to put all required fields together in a template and work with one page "per item" - in most cases (like the skyscraper example) this would be the nicest way - just for a few images which has to be shown on the homepage (and a related text for each image) it would be nicer to have the possibility to edit this on the homepage.

But it would be fine to add a page "Slider Images" below "Home" or have an extra "Meta" area, where one can collect different global settings, like Apeisa suggested.

Link to comment
Share on other sites

There is option, but as far as I know, it only affects the size of the description field.

Doolak, Antti, my bad! As I mentioned, I rarely use it, so I just thought, that it means number of description fields/inputs; I now checked it out, and I stand corrected. Thanks Antti and sorry for confusing you, Doolak.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...