OS Property support center

How to add the chosen image for categories to code

  • Ranala
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
10 years 10 months ago #46402 by Ranala
Hello Dam,

want to show the image, which is related to the OS Property Admin - Property Information - Manage Categories - Photo

I modified the file modules\mod_propertyautosearch\tmpl\default.php with a fixed image and this is working fine.
The image is shown before the 'category_name' when you're opening the 'Advanced Search' at the 'attractionbooker.com' web page (Login: as - password: asdf).

Here the related code:
Code:
<label class="checkbox"> <input <?php echo $checkedCate; ?> class="os-autosearch" value="<?php echo $valueCate;?>" name="category_ids[]" type="checkbox" id="category_<?php echo $category->id; ?>" onclick="javascript:modOspropertyChangeCategoty('<?php echo $category->id; ?>')"> <?php echo "&nbsp;" ; ?> <?php echo "<img src=\"/modules/mod_propertyautosearch/assets/images/funpark_icon.jpg\" width=\"18\" height=\"18\">"; ?> <?php echo "&nbsp;" ; ?> <?php echo $category->category_name; ?> </label>

Instead of the fixed image file 'funpark_icon.jpg' I want to use the image files which are saved for each category at OS Property Admin - Property Information - Manage Categories - Photo. I think this is the variable 'category_image' . How to change the code for this ?

Thanks Rainer

Please Log in or Create an account to join the conversation.

More
10 years 10 months ago #46407 by Mr. Dam
Hi,
I am not sure about your code because it's your module. But to get the images of categories in OS Property, you can setup the link to images > osproperty > categories
And the column name in #__osrs_categories table is: category_image
Thanks
Dam

Please Log in or Create an account to join the conversation.

  • Ranala
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
10 years 10 months ago - 10 years 10 months ago #46413 by Ranala
Thank you, Dam,

Thats the code of the module you wrote for me.

So instead of
Code:
<?php echo "<img src=\"/modules/mod_propertyautosearch/assets/images/funpark_icon.jpg\" width=\"18\" height=\"18\">"; ?>

I have to modify the path to
Code:
<?php echo "<img src=\"/images/osproperty/categories/funpark_icon.jpg\" width=\"18\" height=\"18\">"; ?>
right ?

Then there's one question left: what code I have to modify for the variable category_image of each category instead of the fixed file 'funpark_icon.jpg' ?

This is not working
Code:
<?php echo "<img src=\"/images/osproperty/categories/$category->category_image \" width=\"18\" height=\"18\">" ; ?>

Regards Rainer
Last edit: 10 years 10 months ago by Ranala.

Please Log in or Create an account to join the conversation.

More
10 years 10 months ago #46439 by Mr. Dam
You must sure the variable $category contains all the information of the category
And you can use this code to show the category image
[phpcode]
<?php echo "<img src=\"".Juri::root()."images/osproperty/categories/$category->category_image \" width=\"18\" height=\"18\">" ; ?>
[/phpcode]
Thanks
Dam

Please Log in or Create an account to join the conversation.

  • Ranala
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
10 years 10 months ago #46441 by Ranala
Thank you, Dam,

can you please check the code you sent me with post #46439 again - I tried it with three modifications without success
1.
Code:
<?php echo "<img src=\"".Juri::root()."images/osproperty/categories/$category->category_image \" width=\"18\" height=\"18\">" ; ?>
2.
Code:
<?php echo "<img src=\"".Juri::root()."images/osproperty/category/$category->category_image \" width=\"18\" height=\"18\">" ; ?>
3.
Code:
<?php echo "<img src=\"".Juri::root()."images/osproperty/$category->category_image \" width=\"18\" height=\"18\">" ; ?>

4. with a static image file it is working fine
Code:
<?php echo "<img src=\"/modules/mod_propertyautosearch/assets/images/funpark_icon.jpg\" width=\"18\" height=\"18\">"; ?>

Don't know what you mean when saying
Code:
You must sure the variable $category contains all the information of the category
All images are on server at path images/osproperty/category and will be displayed at OS Admin Categories (see attached file), but the file names have changed. For example the file underwater_icon.jpg chnged to 1403531132_underwater_icon.jpg

Thanks Rainer
Attachments:

Please Log in or Create an account to join the conversation.

More
10 years 10 months ago #46656 by Mr. Dam
Hi Ranala,
I know you want to show the category image, but you should retrieve the data of category from MySQL data table first.
For example
$db->setQuery("Select * from #__osrs_categories where id = 'cat_id'");
$category = $db->loadObject();
So the $category is an object to store all the information of category with id is cat_id

So if you have cat_id, you will be able to get data (include images) of one category
I can't explain more details, because it's very easy in technical.

Thanks
Dam

Please Log in or Create an account to join the conversation.

  • Ranala
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
10 years 10 months ago #46662 by Ranala
Hello Dam,

sorry, that I have to disturb you again with this, but my knowledge is not enough. I'm trying since more than two hours to get the right syntax for the changes you recommended, but without success. I don't find the right position to put the code for a working solution.

I'm sending you the default.php file.
At row 87 I have the fix image, which is working now for all categories and which I want to change with the variable of the category photos which are saved in the database of OS Property Admin.

You're saying, that it is easy for you, to change it. Would you please so kind, to add the missing code for database retrieve and displaying the category image.

Thanks in advance - Rainer

Please Log in or Create an account to join the conversation.

  • Ranala
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
10 years 10 months ago #46663 by Ranala
file didn't load up ?

Please Log in or Create an account to join the conversation.

  • Ranala
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
10 years 10 months ago #46664 by Ranala
.php files are not uploading - changed file extension to .txt.
Attachments:

Please Log in or Create an account to join the conversation.

More
10 years 10 months ago #46667 by Mr. Dam
Hi Ranala,
I have reviewed the code you sent. I want to ask you : what's the variable $categories. Where and how you get that variable in the code file?
Thanks
Dam

Please Log in or Create an account to join the conversation.

Moderators: Mr. DamNguyen Phu Quan