(SOLVED) Create Title field to "Add Items (From Web Browser)" page

Alexandra70

Joined: 2004-12-08
Posts: 143
Posted: Fri, 2008-02-01 02:29

Hello!!

I need help creating a code (inside ItemAddFromBrowser.tpl I suppose??) that would add the Title field (above the Caption field) to the "Add Items (From Web Browser)" page.

I found the post below, but it didn't work.
http://gallery.menalto.com/node/57487

Thank you,
Alex

 
Alexandra70

Joined: 2004-12-08
Posts: 143
Posted: Sat, 2008-02-02 17:17

Anyone?

 
Alexandra70

Joined: 2004-12-08
Posts: 143
Posted: Thu, 2009-09-24 04:32

Well, no one responded, and this Topic had already gone to the second page here...

I figured a solution to this yesterday... gosh.. can't believe it worked.... was on it for maybe about 5 hours.

I will post the solution here just in case someone needs this, because I could not find a solution at all through Search. I guess it doesn't exist.

Don't laugh at how silly this looks or how complicated I made it... but it WORKED!! Since I can't write PHP, all I could do was change things around or copy PHP from other files and only changed what I knew how to change.

First of all, I needed this so bad because in the "Add from Browser" page, there was only a File upload field and a Caption field.

My Gallery will not display the "Summary" anymore for either Albums nor Pics as my Users would write really LONG "Summaries". I want the Photo Thumbs page (inside Album) to look neat. Just the photo Title, and then the Description would only be seen on the actual photo page.

So, back to the "Add from Browser" page...
I wanted my Users to set a Title and a Description to each photo when they upload them.

The only option on the bottom of that page was:

Set item titles from:
Filename (didn't want that one)
Blank (didn't want that either)
Caption (That was ok).

Then, my brain neurons finally connected and I realized that I had posted this stupid Topic, without explaining what I needed to accomplish. No wonder no one responded.

The MAIN problem was the "Assign caption to: Summary Description"

I already had a way to set the "Title" for the uploaded pic...

Just pick "Set item titles from: Caption" and the UNCHECK BOTH "Assign caption to: Summary Description"

Voilá... that would take care of JUST the Title without setting Summary & Description with the same thing.
I knew that, after all these years using Gallery.. But if I used that feature to set the Title, then how would I set the Description upon upload too??

I think that it's unnecessary work when people need to go to "Edit Captions" later to either set the Title OR the Description because they couldn't do both at the same time from the "Add from Browser" page.

So if I already used the "Set item titles from: Caption" to set the Title... if I did the other way around and "Set item titles from: Caption" to set the Description by leaving "Assign caption to: Description" CHECKED, then I wouldn't have the Title anymore!!!!! Duh!!!!

It was either one or the other.

So there was no way to set BOTH at the same time.

That's why I came here asking how to create a Title field.
I could have instead, asked how to create a Description field too...

Either solution would have helped me.

And I needed to get this done ASAP.. and waited and waited and no one replied.

So here's how I fixed it. (sorry for the long introduction... just wanted to explain what my real problem was, as I noticed that the Topic question seemed quite stupid)

-----------------------------

First, I had to set the default of "Set item titles from:" from "base filename" to "Caption". (found a post here explaining that)

Edit modules/core/templates/local/ItemAddFromBrowser.tpl

Change

  {g->text text="Set item titles from:"}
  <select name="{g->formVar var="form[set][title]"}">
    {html_options options=$ItemAddFromBrowser.titleList selected=$form.set.title}

To

  {g->text text="Set item titles from:"}
  <select name="{g->formVar var="form[set][title]"}">
    {html_options options=$ItemAddFromBrowser.titleList selected='caption'}

Then I needed to make sure that "Assign caption to: Summary Description" were BOTH UNCHECKED by default.

So I removed (or you can comment it out) the following:

(still in ItemAddFromBrowser.tpl)

  {g->text text="Assign caption to:"}
  <input type="checkbox" id="cbSummary"{if !empty($form.set.summary)} checked="checked"{/if}
   name="{g->formVar var="form[set][summary]"}"/>
  <label for="cbSummary"> {g->text text="Summary"} </label>
  &nbsp;

  <input type="checkbox" id="cbDesc"{if !empty($form.set.description)} checked="checked"{/if}
   name="{g->formVar var="form[set][description]"}"/>
  <label for="cbDesc"> {g->text text="Description"} </label>

Then I had to HIDE that whole bottom section of the "Add from Browser" page.. so that my Users would NOT make any changes there.

So I found this post:
http://gallery.menalto.com/node/59217

So basically, to HIDE that section... you do this:

Still editing ItemAddFromBrowser.tpl, you change the gbBlock:

<div class="gbBlock">
  {g->text text="Set item titles from:"}
  <select name="{g->formVar var="form[set][title]"}">
    {html_options options=$ItemAddFromBrowser.titleList selected='caption'}
  </select>

To

<div class="gbBlock-none">
  {g->text text="Set item titles from:"}
  <select name="{g->formVar var="form[set][title]"}">
    {html_options options=$ItemAddFromBrowser.titleList selected='caption'}
  </select>

But WAIT.. Now you need to edit your Theme's theme.css file.

Add this:

.gbBlock-none {
display:none;
}

Voilá... the section "Set item titles from:" of the "Add from Browser" page is gone!!

If you also want that "Gallery can create thumbnails at upload time" to be gone too, the just move the closing (/div) to underneath {/foreach}, as in:

{* Include our extra ItemAddOptions *}
{foreach from=$ItemAdd.options item=option}
  {include file="gallery:`$option.file`" l10Domain=$option.l10Domain}
{/foreach}
</div> 

---------------

Ok... So that's done. I had my TITLE FIELD set. Now I needed to create a Description field and had NO CLUE on how to do that since I cannot write PHP.

I searched this Forum for DAYS.. and all I could find was a post that showed how to add a Keywords field to that same page.

So I tried to understand the Greek-To-Me-PHP and see if I could change the Keywords code given on that post to make the Description field instead.

And I got it!!!

    <h4> {g->text text="Description"} </h4>
    <textarea rows="2" cols="60" name="{g->formVar var="form[description][$iteration]"}"></textarea>

Ta-Daaaa.. I now had both my Title and Description Field. Yippeeee...

I still did some more customizing like:
Kept it simple by removing BBCode markup.
Added a yellow line to separate each "Title", "Description", "File" blocks of 3, when people clicked on "More Upload Boxes..."
Moved the File field below Title and Description.
Changed the name-text of the "old" Caption field to "Title".
Added a character limit to the Title field.
And changed the Title field from <textarea to <input type="text".

    <h4> {g->text text="Caption"} </h4>
    <textarea rows="2" cols="60" name="{g->formVar var="form[caption][$iteration]"}"></textarea>

To

    <h4> {g->text text="Title"} - (125 chars. max)</h4>
    <input type="text" maxlength="60" size="75" name="{g->formVar var="form[caption][$iteration]"}"/>

And here's how it looks... MADE BY ME!!! (so damn proud) (<---- SNOB!!!)

[img]http://www.makeachildsmile.org/images/other/additems.jpg[/img]

Nice!!! Mission accomplished!!

 
mareluna
mareluna's picture

Joined: 2006-11-05
Posts: 41
Posted: Fri, 2008-02-15 08:25

But... you're a Genius !!!! Thank U very much for your GREAT work !!!

Versione di Gallery = 2.2.4 core 1.2.0.6
Versione PHP = 4.4.7 apache2handler
Webserver = Apache/2.0.52 (CentOS)

 
hicsong

Joined: 2008-02-01
Posts: 8
Posted: Wed, 2008-02-20 03:52

For some reason my Description doesnt works .. still save as Blank.
I had it all installed/replaced correctly, except this following..

Quote:

<h4> {g->text text="Description"} </h4>
<textarea rows="2" cols="60" name="{g->formVar var="form[description][$iteration]"}"></textarea>

mine is ver. 2.4 Full. Please give some more hint or have you try it on full version yet? :)

Thanks

 
Alexandra70

Joined: 2004-12-08
Posts: 143
Posted: Wed, 2008-02-20 04:14

Sorry... I didn't understand what the problem is...

What do you mean "still save as Blank"

Please explain more what is wrong and what are you trying to accomplish.

I don't think it matters if you have the full version or not... The full one comes with a bunch of modules. The most important files (core) and modules will be the same no matter if you have the full version or not.

 
hicsong

Joined: 2008-02-01
Posts: 8
Posted: Wed, 2008-02-20 05:45

I mean file has been added but when I edit file . Description box is empty.

Quote:
<h4> {g->text text="File"} </h4>
<input type="file" size="60" name="{g->formVar var="form[$iteration]"}"/>

<h4> {g->text text="Title"} - (125 chars. max)</h4>
<input type="text" maxlength="60" size="75" name="{g->formVar var="form[caption][$iteration]"}"/>

<h4> {g->text text="Description"} </h4>
<textarea rows="2" cols="60" name="{g->formVar var="form[desc][$iteration]"}"></textarea>

</div>

I am paste it correctly? <h4>

Quote:
{g->text text="Description"} </h4>
<textarea rows="2" cols="60" name="{g->formVar var="form[description][$iteration]"}"></textarea>

somewhere around Lines 48-50
and Result both Title and Description fields got the same information ..

Before:
>File
>Title: Test Title
>Desc: Test Desc

AFTER
>File Added
>Title: Test Title
>Desc: blank

btw, if you dont mind .. may I see your [ ItemAddFromBrowser.tpl ] working codes?

 
Alexandra70

Joined: 2004-12-08
Posts: 143
Posted: Fri, 2008-02-22 05:18

Here is my file.

Keep in mind, that I made A LOT of changes to it.

Even some small modifications (cosmetics) AFTER I posted this topic. But what you want still remains the same.

{*
 * $Revision: 15342 $
 * If you want to customize this file, do not edit it directly since future upgrades
 * may overwrite it.  Instead, copy it into a new directory called "local" and edit that
 * version.  Gallery will look for that file first and use it if it exists.
 *}
{if !$ItemAddFromBrowser.uploadsPermitted}
<div class="gbBlock giError">
  {g->text text="Your webserver is configured to disallow file uploads from your web browser at this time.  Please contact your system administrator for assistance."}
</div>
{else}

{if !empty($form.error.upload)}
<div class="gbBlock giError"><h2>
  {g->text text="There was a problem processing your request, see below for details."}
  </h2>
  <div class="giWarning">
  {foreach from=$ItemAddFromBrowser.status item=statusEntry}
    {$statusEntry.warnings.0}<br/>
  {/foreach}
  </div>
</div>
{/if}

<div class="gbBlock">
  <p class="giDescription">
    {g->text text="Upload files directly from your computer."}
    {g->text text="Enter the full path to the file and an optional caption in the boxes below."}
  </p>

  <p class="giDescription">
    {if $ItemAddFromBrowser.maxFileSize == 0}
      {g->text text="<b>Note:</b> You can upload up to %s at one time.  If you want to upload more than that, you must upload the files separately, use a different upload format, or ask your system administrator to allow larger uploads." arg1=$ItemAddFromBrowser.totalUploadSize}
    {else}
      {g->text text="<b>Note:</b> You can upload up to %s at one time.  No individual file may be larger than %s. If you want to upload more than that, you must upload the files separately, use a different upload format, or ask your system administrator to allow larger uploads." arg1=$ItemAddFromBrowser.totalUploadSize arg2=$ItemAddFromBrowser.maxFileSize}
    {/if}
  </p>

  {assign var="UPLOAD_BOX_COUNT" value = "20"}
  {assign var="VISIBLE_BOX_COUNT" value = "2"}
  {section name="uploadBoxes" loop=$UPLOAD_BOX_COUNT}
  {assign var=iteration value=$smarty.section.uploadBoxes.iteration}
  <div id="fileDiv_{$iteration}" {if $iteration > $VISIBLE_BOX_COUNT} style="display:none"{/if}>
  
    <h4> {g->text text="Title"} - (120 chars. max)</h4>
    <input type="text" size="125" maxlength="120" name="{g->formVar var="form[caption][$iteration]"}"/> 
    
    <h4> {g->text text="Description"} </h4>
    <textarea rows="2" cols="65" name="{g->formVar var="form[description][$iteration]"}"></textarea>    
    
    <h4> {g->text text="File"} </h4>
    <input type="file" size="60" name="{g->formVar var="form[$iteration]"}"/>
    
    <br><br>
    
    <img src="../images/line.gif" width="100%" height="21">

    <br>
    
  </div>

  {/section}
   
  {if $UPLOAD_BOX_COUNT > $VISIBLE_BOX_COUNT}
  <script type="text/javascript">
	// <![CDATA[
	document.write('<h4><a id="addOne" href="javascript:addOne()">{g->text text="More Upload Boxes..."}</a></h4>');
	var fileIndex = {$VISIBLE_BOX_COUNT};
	{literal}
	function addOne() {
		var link = document.getElementById('addOne');
		link.blur();
		document.getElementById('fileDiv_' + ++fileIndex).style.display = 'block';
		if (fileIndex >= {/literal}{$UPLOAD_BOX_COUNT}{literal}) {
			link.style.display = 'none';
		}
	}
      // ]]>
    {/literal}</script>
  {/if}
</div>

<div class="gbBlock-none">
  {g->text text="Set item titles from:"}
  <select name="{g->formVar var="form[set][title]"}">
    {html_options options=$ItemAddFromBrowser.titleList selected='caption'}
  </select>
  &nbsp; 

{* Include our extra ItemAddOptions *}
{foreach from=$ItemAdd.options item=option}
  {include file="gallery:`$option.file`" l10Domain=$option.l10Domain}
{/foreach}
</div>   

<div class="gbBlock gcBackground1">
  <input type="submit" class="inputTypeSubmit"
   name="{g->formVar var="form[action][addFromBrowser]"}" value="{g->text text="Add Items"}"/>
</div>
{/if}
 
Ryno80

Joined: 2008-04-07
Posts: 12
Posted: Thu, 2008-11-06 22:26

Alexandra70, thank you so much for sharing such an extensive customization for the add items page, I have used it and it has been sooooo helpful, however I am having the same problem as hicsong up there did, where the Description comes out blank after upload. Was there ever a solution found for this issue? Any ideas?

 
Alexandra70

Joined: 2004-12-08
Posts: 143
Posted: Sat, 2008-11-08 20:34

Hi Ryno80,

Well, I just tested my Gallery, uploaded an image using my tweaked Add Items page, and the Description came out just fine after the Upload.

So I really don't know what's going on there.

I am attaching my file here again... Keep in mind, that I have Gallery version = 2.2.4 core 1.2.0.6

So if you have a newer version, maybe that could be the problem. Or maybe do everything all over again... step-by-step as I did above, as you could have missed something.

Alex

 
kferranti4

Joined: 2008-02-10
Posts: 26
Posted: Sun, 2008-11-09 19:43

Oh this will come in handy after I solve a few other problems I am going to try this. Thanks for posting your changes for us.

 
Ryno80

Joined: 2008-04-07
Posts: 12
Posted: Mon, 2008-11-10 22:02

Alexandra70, thanks for the reply and attachment, I re-did everything step by step and triple checked the code and still no luck. Are you sure that you didn't edit ItemAddFfromBrowser.inc as well in this process??

 
Alexandra70

Joined: 2004-12-08
Posts: 143
Posted: Tue, 2008-11-11 02:25

Ryno, first of all... are you using the same G2 Version as me???

Second... don't know if THEME matters... but I am using Classic.

I reviewed all my notes (I always write down all the changes I made to Gallery so I know what and where was changed) just in case all my files someday disappear and I need to do all the customizing from scratch again........ and I did not find any notes that I modified the INC file. But just in case, here it is attached.

Then going through my notes, I found one other customization that I will paste here... BUT.... I don't think that it has ANYTHING to do with your Description not setting.

But here it is just in case because it's the only other thing I could think of, that has to do with adding items.

What is does is the following:
When my users upload a file named "ourtriptothebeachwithuncletom.jpg" or "DC19374785639.jpg" I always hated that when you were viewing a picture, the NAME of the file would show on the URL and on the breadcrumb... Some files had stupid names, some were too long, etc... So I wanted it all to be nice, clean and uniform.

So any image added, is automatically renamed to "aaa.jpg", "aaa_001.jpg" and so on....

Edit modules/core/classes/helpers/GalleryItemHelper_medium.class

    function addItemToAlbum($fileName, $itemName, $title, $summary,
			    $description, $mimeType, $albumId, $symlink=false) {
	global $gallery;
<------------ ADD THE LINES BELOW ------------- >
	$platform = $gallery->getPlatform();
	list () = GalleryUtilities::getFileNameComponents($fileName); 
	$itemName = 'aaa' . $extension

Again, I think this has nothing to do with the Desc. problem... but... oh well.

I think that it either has to be if we are on different G2 Versions... or.... maybe different THEMES.

The only way you can rules these in or out... would be to install a TEST Gallery if you can, and make sure you get the same version that I use, and then activate the Classic Theme. If my modifications work, then that's what it was. Just a thought... though a lot more work to do.

Keep asking if you think of anything else... I know how frustrating it is when you can't get something to work or worse, when it partially works!

Alex

 
blw91126

Joined: 2004-11-12
Posts: 81
Posted: Tue, 2008-12-02 05:44

I think I figured it out. By PURE LUCK.

Anyway I was having the same problem with descriptions not showing up. I edited the ItemAddFromBrowser.inc

Find

 	/* Placeholder for later */
		if (!empty($form['tmp_name'][$i]) && !empty($form['size'][$i])) {
		    $file = array('name' => $form['name'][$i],
				  'type' => $form['type'][$i],
				  'tmp_name' => $form['tmp_name'][$i],
				  'size' => $form['size'][$i],
				  'caption' => $form['caption'][$i]);

and make it look like this

	/* Placeholder for later */
		if (!empty($form['tmp_name'][$i]) && !empty($form['size'][$i])) {
		    $file = array('name' => $form['name'][$i],
				  'type' => $form['type'][$i],
				  'tmp_name' => $form['tmp_name'][$i],
				  'size' => $form['size'][$i],
				  'description' => $form['description'][$i],
				  'caption' => $form['caption'][$i]);

then find

		    $description = empty($form['set']['description']) ? '' : $file['caption'];

and make it

		    $description = empty($form['set']['description']) ? $file['description'] : $file['description'];

And viola! Descriptions are added with the mod mentioned above.

 
Alexandra70

Joined: 2004-12-08
Posts: 143
Posted: Fri, 2008-12-05 03:35

Good job blw91126!!!! I am glad it worked out!!!

Funny how my version works without those modifications... weird!!

At least people will have 2 options then, if one does not work.

Thanks for posting!!

Alex

 
christmasdispla...

Joined: 2009-04-02
Posts: 2
Posted: Thu, 2009-04-02 08:51

Hi guys.

This is a great find and went without a hitch. Including the description on the image once I applied the second fix.

One question though, How do I get the description to show on the gallery page that shows the thumbnails?

I have attached an image to show you.

Thanks in advance for any help.

 
christmasdispla...

Joined: 2009-04-02
Posts: 2
Posted: Thu, 2009-04-02 09:14

Well you wouldn't believe it. I thought I would 'poke' around the album.tpl file to see if I could see anything and guess what! I solved it.

All I did was replace all mention of the word summary with the word Description or description (where the case was different).

Hope it helps.