Page 3 of 4

The problem is other

Posted: 28 Jan 2008, 01:54
by Jan
The problem is other. Categories view works great with database... It gets data from database, It gets e.g. filename --> 001.jpg... so it wants to show this file, but it cannot find it on the disc (there is a check) so it displays no_image.jpg...

Possible problems can be: there is a bad path to the image, which should be displayed next to category name and if Phoca Gallery checks the file, it cannot find it and displays no_image.jpg...

It seems like you know something about PHP. Please go to components/com_phocagallery/helpers/phocagallery.php , row 89 and add here:

print_r($file_thumbnail);


and you will see the path to the image, which should be displayed... Then you check manually, if this file resp. path exists....

Jan

I did what you sugge

Posted: 28 Jan 2008, 03:21
by Vedaro
I did what you suggested:

it returns "Array". The value at index 0 is "2". But I think the problem is, that $filename is "0" (print_r($filename); gives 0).

I think a problem is, that in front/views/categories/tmpl/default.php the values for $category->linkthumbnailpath

and without my change I mentioned in my last post for $category->link

are both empty.

I think they are set in front/models/categories.php in line 77 $this->_data_outcome->link = "";

and 79 $this->_data_outcome->linkthumbnailpath = "";


When I enter dummy values there, they are displayed via default.php in my category listing.

If I enter
$this->_data_outcome->link = JRoute::_('index.php?option=com_phocagallery&view=c
ategory&id='. $value2->slug);


it fixes the link issue for me.

Remains the linkthumbnailpath issue: $query_filename is not set.

I fixed it like this: front/models/categories.php lines 78ff:


$query_filename = $this->_buildQueryFilename($value2->id);
$filename_list = $this->_getList($query_filename);
$filename = $filename_list[0]->filename;
$this->_data_outcome->filename = $filename;
$file_thumbnail = PhocaGalleryHelper::displayFileOrNoImage($filename, "");
$this->_data_outcome->linkthumbnailpath = $file_thumbnail['rel'];
$this->_data_filename = $filename_list;




I had also fix the SQL query in _buildQueryFilename in the same file (not sure if it is semantical correct):

$query = 'SELECT filename AS filename FROM #__phocagallery WHERE catid='.$catid.
' AND published = 1 ORDER BY ordering LIMIT 1';



So now the category listing works for me. Can you check my changes?

Some questions: Is t

Posted: 28 Jan 2008, 03:26
by Vedaro
Some questions: Is there yet a possibility to show only categories of level "1" in the listing, so subcategories are not listed but accessable through the "main" categories?

And do you have a SVN or something? It could be that we have different files front/models/categories.php made a none finished impression on me, in my version the features couldn't have worked at all...

1. There is not poss

Posted: 28 Jan 2008, 15:53
by Jan
1. There is not possibility to show only level "1" ....
2. SVN - you can find the SVN on joomlacode.org
3. The SQL query should be:

$query = 'SELECT filename AS filename FROM #__phocagallery WHERE catid='.$catid.' AN
D ordering=(SELECT MIN(ordering) FROM #__phocagallery WHERE published = 1 AND catid='
.$catid.') LIMIT 1';



How should it work:

Phoca gallery select the filename from database, which should be displayed next to category in categories view. User can define which file will be displayed. The file with the lowest ordering number will be displayed, so if you want to display some image next to category you will move it to the first place in your listing...
If the file with the lowest ordering is unpublished, it is displayed the next file with second lowest ordering...

It should works without problems... Then PHP script get this file name and add the path to this file name... then it comes check if this file exists on the server disc... If not, Phoca Gallery display no_image.jpg instead of this image

Try to use this SQL script in your database (vie PHPMyAdmin)
It is from 1.3

$query = 'SELECT filename AS filename FROM #__phocagallery WHERE catid='.$catid.' AN
D ordering=(SELECT MIN(ordering) FROM #__phocagallery WHERE published = 1 AND catid='
.$catid.') LIMIT 1';


- you must change #__ to your-prefix_ and
- $catid to catid number which exists

You should get the ordering number. If you get it, the problem isn't related to database but to path

Hi Jan,I

Posted: 28 Jan 2008, 16:37
by Vedaro
Hi Jan,

I ran the script in the database (I tried it already tonight, that's why I changed my SQL-statement):

SELECT filename AS filename
FROM jos_phocagallery
WHERE catid =1
AND ordering = (
SELECT MIN( ordering )
FROM jos_phocagallery
WHERE published =1
AND catid =1 )
LIMIT 1



the result was

#1064 - You have an error in your SQL syntax. Check the manual that corresponds
to your MySQL server version for the right syntax to use near 'SELECT MIN(ordering)
FROM jos_phocagallery WHERE published = 1



the MySQL-Version of my hoster is 4.0.27-max-log

Doesn't my statement do the same but without the subquery?
$query = 'SELECT filename AS filename FROM #__phocagallery WHERE catid='.$catid.
' AND published = 1 ORDER BY ordering LIMIT 1';



It selects a single filename that has my category and is published - the first one because it's ordered by ordering.


But even if the statement you gave me would work in my database, the gallery-listing with the link would not - please take a look at line 77 to 84 of com_phocagallery/front/models/categories.php - in my opinion this cannot function because the values for link, filename and linkthumbnailpath are set empty and the variable $query_filename is never filled.

$this->_data_outcome->link = "";
$this->_data_outcome->filename = "";
$this->_data_outcome->linkthumbnailpath = "";

$query_filename = $this->_buildQueryFilename($value2->id);
$this->_data_filename = $this->_getList($query_filename);
$this->_data_outcome->filename = $this->_data_filename[0]->filename;
$this->_data_outcome_array[] = $this->_data_outcome;

1. you right with th

Posted: 29 Jan 2008, 02:05
by Jan
1. you right with the SQL, it is to complicated (I have made only one query and then I split it to more queries and didn't optimized it). I have fixed it...

2. Objects:
- $this->_data_outcome->link
- $this->_data_outcome->linkthumbnailpath will not be filled in models (models/categories) but in views (views/categories/view.html.php), because in views Phoca Gallery gets some variables (Params) it needs.

Object:
- $this->_data_outcome->filename will be filled here:

$query_filename = $this->_buildQueryFilename($value2->id);
$this->_data_filename = $this->_getList($query_filename);
$this->_data_outcome->filename = $this->_data_filename[0]->filename;


First - it gets catid ($value2->id)
Second - it gets the filename from the database (catid will be used for parent category)
Third - $this->_data_outcome->filename get this filename

The values are set emty and then they get new values...

Hi Jan,t

Posted: 29 Jan 2008, 02:27
by Vedaro
Hi Jan,

thanks for clearifying that. I didn't test it with my sql-statement without other changes. The sql-statement before didnt work for me, so there was no data. Now there is data in views/categories/view.html.php I do get the links and thumbnails-paths correctly (i did some echos).

But in the end in views/categories/tmpl/default.php

foreach ( $this->categories as $category )
{
echo '<tr>';
echo '<td align="center">'.'<a href="'.$category->link.'">'.JHTML::_( 'image.site'
, $category->linkthumbnailpath, '', '', '', $category->title, 'style="border:0"' ).'
<
/a></td>';
echo '<td><a href="'.$category->link.'" class="category'.$this->params->get( 'page
class_sfx' ).'">'.$category->title.'</a> ';
echo '<span class="small">('.$category->numlinks.')</span></td>';
echo '</tr>';
}



$category->link and $category->linkthumbnailpath are empty again. Do you have any idea about that?


A different thing:

1. There is not possibility to show only level "1" ....

Do you think you could add an option for this? Wouldnt it be just another "WHERE parentid = 0" in the build-query if this option is set...?

level 1... Please, i

Posted: 29 Jan 2008, 02:40
by Jan
level 1... Please, if you know how to change it and you want to change it, just change it for yourself... The problem is that there are 'thousands' of feature requests so if we do all as parameters, there will be thousands of paramters and it will be very confusing...

$categories ... which version of PHP do you use... maybe you get data from database but your objects are not filled

No problem.. I'

Posted: 29 Jan 2008, 02:57
by Vedaro
No problem.. I'll add that for myself, but as I'm a Java-dev and dont know PHP very well I would have liked an option in backend - because thats what I am not able to do in an easy way.

Ok.. back to topic..

My PHP Version is: 4.4.7

And yes, the objects are treated as local copies only and not changed in the $categories array.

If I change line 50ff in views/categories/view.html.php from this
foreach ($categories as $category)
{
$category->link = JRoute::_('index.php?option=com_phocagallery& view=category&id=
'. $category->slug );
$file_thumbnail = PhocaGalleryHelper::displayFileOrNoImage($category->filename,
$img_cat_size);
$category->linkthumbnailpath= $file_thumbnail['rel'];
}



to this
foreach ($categories as $key => $category)
{
$categories[$key]->link = JRoute::_('index.php?option=com_phocagallery&view=catego
ry&id='. $category->slug );
$file_thumbnail = PhocaGalleryHelper::displayFileOrNoImage($category->filename,
$img_cat_size);
$categories[$key]->linkthumbnailpath = $file_thumbnail['rel'];
}



it works for me. Maybe you could explain why that happens?

Posted: 29 Jan 2008, 03:19
by Jan
Great... this is the problem... I use this if I do some scripts which are working under PHP5 (object oriented) but not under PHP4 (not so object oriented ... I cannot say not fully object oriented because PHP5 is not fully object oriented too... you cannot inherit attributes from e.g. 2 classes and....) ... The problem is, I use PHP5 for testing... sometimes I forgot that it cannot work under PHP4 ... so sometimes you must add new value with help of array not object if you want it will work under PHP4...

Great I will change it ... Thank you

BTW: you say, you don't know PHP because you are Java-dev... I think, you undestand PHP very good ... what should I say: I am economist who didn't speak English and needed a component for Joomla... There was no component what I needed so I must do it myself... And now ...