Author Topic: Using image tags on a custom page.  (Read 66975 times)

0 Members and 1 Guest are viewing this topic.

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: Using image tags on a custom page.
« Reply #45 on: November 13, 2007, 09:10:19 AM »
Hi guys, is me again,

I tried everything to link $image_row['image_name'] to the details.php to view the image, but I get everytime a parse error.

Quote
$featured_images_list .= "<tr><td>".$image_row['image_name']."</td><td>".$image_row['image_hits']."</td></tr>";

That means when you click on the name of the image you go to the datails.php.

NOTE: I tries the same like on the TOP.PHP but ...parse error
Any help please?

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Using image tags on a custom page.
« Reply #46 on: November 13, 2007, 01:24:55 PM »
Please post full code (in bbcode) for help.
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: Using image tags on a custom page.
« Reply #47 on: November 13, 2007, 01:50:18 PM »
Here is the code:

Code: [Select]
$sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_date, i.image_active, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_name")."
        FROM (".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c)
        LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id)
        WHERE i.image_active = 1 AND i.image_honor = 1 AND c.cat_id = i.cat_id AND i.cat_id IN (".get_auth_cat_sql("auth_viewcat").")
        ORDER BY i.image_date DESC
        LIMIT 20";
$result = $site_db->query($sql);
$num_rows = $site_db->get_numrows($result);
if (!$num_rows)  {
   $featured_images_list = $lang['no_images'];
}
 
else  {
   $featured_images_list = "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"4\"><tr><td>Image Name</td><td>Current Hits</td></tr>";
   while ($image_row = $site_db->fetch_array($result)){
   $featured_images_list .= "<tr><td>".$image_row['image_name']."</td><td>".$image_row['image_hits']."</td></tr>";
}
}
  $featured_images .= "</table>\n";
$site_template->register_vars("featured_images_list", $featured_images_list);
unset($featured_images_list);

Thanks in advance

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Using image tags on a custom page.
« Reply #48 on: November 13, 2007, 02:09:07 PM »
[edit] - is post of custom page  8O ...
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Using image tags on a custom page.
« Reply #49 on: November 13, 2007, 02:17:05 PM »
I edit post.
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: Using image tags on a custom page.
« Reply #50 on: November 13, 2007, 02:23:35 PM »
Yes.


I just want to embed a link to $image_row['image_name' to go to the image page (/details.php?image_id=XXX):

In this line:
($featured_images_list .= "<tr><td>".$image_row['image_name']."</td><td>".$image_row['image_hits']."</td></tr>")

At moment I get the image name like:
Foto of spain
I want it this way:
Code: [Select]
<a href="http://4images.com/details.php?image_id=XXX">Foto of spain</a>
On the top.php you find also a list of images and when you click on the image name you go to details.php to view the photo.

Offline mawenzi

  • Moderator
  • 4images Guru
  • *****
  • Posts: 4.500
    • View Profile
Re: Using image tags on a custom page.
« Reply #51 on: November 13, 2007, 02:46:08 PM »
... replace ...
Code: [Select]
<td>".$image_row['image_name']."</td>

... with ...
Code: [Select]
<td><a href=\"".$site_sess->url(ROOT_PATH."details.php?image_id=".$image_row['image_id'])."\">".$image_row['image_name']."</a></td>
« Last Edit: November 13, 2007, 04:11:43 PM by mawenzi »
Your first three "must do" before you ask a question ! ( © by V@no )
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

You are on search for top 4images MOD's ?
- then please search here ... Mawenzi's Top 100+ MOD List (unsorted sorted) ...

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: Using image tags on a custom page.
« Reply #52 on: November 13, 2007, 04:15:38 PM »
No problem Guru.

My custom page is looking now beter than ever.
Respect for you skills! :wink:

Offline mawenzi

  • Moderator
  • 4images Guru
  • *****
  • Posts: 4.500
    • View Profile
Re: Using image tags on a custom page.
« Reply #53 on: November 13, 2007, 04:17:49 PM »
... thanks for your post ...  :mrgreen:
Your first three "must do" before you ask a question ! ( © by V@no )
- please read the Forum Rules ...
- please study the FAQ ...
- please try to Search for your answer ...

You are on search for top 4images MOD's ?
- then please search here ... Mawenzi's Top 100+ MOD List (unsorted sorted) ...

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: Using image tags on a custom page.
« Reply #54 on: November 13, 2007, 07:45:47 PM »
Hi guys,

I am still fighting with the codes of my custom template.
Yesterday we solved a big problem and today I have little one, but I could not solve it myself.

I used the following code to call some information of a user to the custom page:

Code: [Select]
  $sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_date, i.image_active, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_name")."
        FROM (".USERS_TABLE." u, ".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c)
        WHERE i.user_id = 2
        ORDER BY i.user_id DESC
        LIMIT 20";
$result = $site_db->query($sql);
$num_rows = $site_db->get_numrows($result);


if (!$num_rows)  {
   $hobby = $lang['no_images'];
}
else  {
   $hobby = "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"4\"><tr><td>User Name</td><td></td><td>User hobby</td></tr>";
   while ($user_row = $site_db->fetch_array($result)){
   $hobby .= "<tr><td>".$user_row['user_name']."</a></td><td>".$user_row['user_hobby']."</td</td></tr>";
}
}
  $hobby .= "</table>\n";
$site_template->register_vars("hobby", $hobby);
unset($hobby);

The result was 19 user names (no user id=2) and the additonal user fields user_hobby also not!

The result should be:

User name                         Hobby
Marco                                 Running

Can you see please what I did wrong? :?

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Using image tags on a custom page.
« Reply #55 on: November 14, 2007, 12:36:12 AM »
@mawenzi:

Please use format_text with image_name.

Replace:

Quote
<td><a href=\"".$site_sess->url(ROOT_PATH."details.php?image_id=".$image_row['image_id'])."\">".$image_row['image_name']."</a></td>

with:

Code: [Select]
<td><a href=\"".$site_sess->url(ROOT_PATH."details.php?image_id=".$image_row['image_id'])."\">".format_text(trim($image_row['image_name']), 2)."</a></td>
/code]
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: Using image tags on a custom page.
« Reply #56 on: November 14, 2007, 09:02:44 PM »
Any help please :(

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Using image tags on a custom page.
« Reply #57 on: November 14, 2007, 09:03:56 PM »
Sorry ... I no get is say ...
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?

Offline Sun Zaza

  • Sr. Member
  • ****
  • Posts: 399
    • View Profile
Re: Using image tags on a custom page.
« Reply #58 on: November 14, 2007, 09:30:31 PM »
Ok then, I will explain:

I want to have some information from the users table in database.
I want to call the HOBBY of the user.

So the query is: give me as results the hobby of the uder_id=XXX.

On my custom page i use this query, but I think it is not complete or wrong:

Code: [Select]
  $sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_date, i.image_active, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_name")."
        FROM (".USERS_TABLE." u, ".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c)
        WHERE i.user_id = 2
        ORDER BY i.user_id DESC
        LIMIT 20";
$result = $site_db->query($sql);
$num_rows = $site_db->get_numrows($result);



Here is the code of my custom page:

Code: [Select]
<?php
$main_template 
'special3';

define('GET_CACHES'1);
define('ROOT_PATH''./');
include(
ROOT_PATH.'global.php');
require(
ROOT_PATH.'includes/sessions.php');
$allowed_users_access_page = array(2); // Change for all user ID need.
if (function_exists('check_for_valid_user_access_page') && !check_for_valid_user_access_page($allowed_users_access_page) && $user_info['user_level'] < ADMIN) {
   
redirect($url);
}
$user_access get_permission();
include(
ROOT_PATH.'includes/page_header.php');
include(
ROOT_PATH.'includes/stats.php');

            
$additional_sql "";
if (!empty(
$additional_image_fields)) {
  foreach (
$additional_image_fields as $key => $val) {
    
$additional_sql .= ", i.".$key;
  }
}



 
//Hobby
  
$sql "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_date, i.image_active, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.""user_name")."
        FROM ("
.USERS_TABLE." u, ".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c)
        WHERE i.user_id = 2 
        ORDER BY i.user_id DESC
        LIMIT 20"
;
$result $site_db->query($sql); 
$num_rows $site_db->get_numrows($result); 


if (!
$num_rows)  { 
   
$hobby $lang['no_images']; 

else  {
   
$hobby "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"4\"><tr><td>User Name</td><td></td><td>User hobby</td></tr>";
   while (
$user_row $site_db->fetch_array($result)){ 
   
$hobby .= "<tr><td>".$user_row['user_name']."</a></td><td>".$user_row['user_hobby']."</td</td></tr>";


  
$hobby .= "</table>\n";
$site_template->register_vars("hobby"$hobby); 
unset(
$hobby);



On my custom page I get 20 users (inclusief GUEST) [b](This is wrong because I asked fot the user_id 2)[/b] and nothing about the hobby. [b](The hobby field stays empty)[/b]



//-----------------------------------------------------
//--- Clickstream -------------------------------------
//-----------------------------------------------------
$clickstream "<span class=\"clickstream\"><a href=\"".$site_sess->url(ROOT_PATH."index.php")."\" class=\"clickstream\">".$lang['home']."</a>".$config['category_separator']."Special"."</span>";

//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
$site_template->register_vars(array(
  
"clickstream" => $clickstream,
  

));
$site_template->print_template($site_template->parse_template($main_template));

include(
ROOT_PATH.'includes/page_footer.php');
?>

Can you see what I did wrong?
Let me know if you need more info from me.
Thanks in advance

Offline thunderstrike

  • 4images Guru
  • *******
  • Posts: 2.327
    • View Profile
Re: Using image tags on a custom page.
« Reply #59 on: November 14, 2007, 09:43:26 PM »
Find:

Quote
$additional_sql = "";
if (!empty($additional_image_fields)) {
  foreach ($additional_image_fields as $key => $val) {
    $additional_sql .= ", i.".$key;   
  }
}

add after:

Code: [Select]
if (isset($additional_user_fields) && is_array($additional_user_fields) && !empty($additional_user_fields)) {
   foreach ($additional_user_fields as $key => $val) {
      $additional_sql .= ", u.".$key;
   }
}

And please replace this:

Code: [Select]
$hobby .= "<tr><td>".format_text(trim($user_row[$user_table_fields['user_name']]), 2)."</a></td><td>".$user_row['user_hobby']."</td</td></tr>";
8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?