Anycontent.php with search function Anycontent.php with search function
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Anycontent.php with search function

Started by mooxe, September 10, 2008, 05:53:30 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

mooxe

Howdy,

I want to enable a quick search within the anycontent.php. Is this wise for php code, I am not sure... anyways... I have done it by cutting out all the stuff I dont want from search.php. I cannot get the names of the checkboxes to show up, how do I fix this? The link is http://www.combatgallery.com/ or a screenshot in case it gets fixed...

http://www.closecombatseries.net/screenshots/public/cpgerrorb735e4822085e12.jpg [Edit GauGau] Replaced hotlinked image with attachment [/Edit]




<?php
/*************************
  Coppermine Photo Gallery
  ************************
  Copyright (c) 2003-2008 Dev Team
  v1.1 originally written by Gregory DEMAR

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License version 3
  as published by the Free Software Foundation.
  
  ********************************************
  Coppermine version: 1.4.18
  $HeadURL: https://coppermine.svn.sourceforge.net/svnroot/coppermine/trunk/cpg1.4.x/anycontent.php $
  $Revision: 4380 $
  $Author: gaugau $
  $Date: 2008-04-12 12:00:19 +0200 (Sa, 12 Apr 2008) $
**********************************************/

/**
* Coppermine Photo Gallery 1.4.14 anycontent.php
*
* This file file gets included in the index.php if you set the option in admin
* can be used to display any content from any program, it is always to be edited
* according to tastes and then used
*
* @copyright 2002,2007 Gregory DEMAR, Coppermine Dev Team
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License V3
* @package Coppermine
* @version $Id: anycontent.php 4380 2008-04-12 10:00:19Z gaugau $
*/

if (!defined('IN_COPPERMINE')) die('Not in Coppermine...');

starttable("100%""Welcome to the Combat Gallery!");

?>

<tr>
  <td class="tableb" >
The Combat Gallery is a new project which intends to create, over time, one of the largest depositories of photos from World War 2. The gallery is planned to be a simple, browsable and highly searchable. The site will also be kept free of cluttered ads, news feeds, polls and anything else that detracts from viewing the galleries. Currently the majority of the photos are from World War 2, as the site grows and evolves we will be adding more categories. The pictures are collected in many ways such as auctions, photo albums and through internet searching. Photos can also be added by you, which go through a approval process to ensure proper descriptions and no duplicates.<br /><br />

The first goal is to specialize in large albums of specific battles. This will be the main effort of the gallery over the next few years.  Secondary goal is to showcase personal photo albums of the veterans who served. Finally, any photos that are collected which cannot be identified to a specific battle will be inserted into the generalized albums such as armament, vehicles, infantry and home front etc etc. If you have images you'd like to submit or if you'd like to help out on this project please email the <a href="mailto:mooxe@closecombatseries.net">Webmaster</a>.</td>
</tr>

<?php


define
('SEARCH_PHP'true);


echo <<< EOT

<form method="post" action="thumbnails.php" name="searchcpg">
EOT;

starttable('100%'$lang_search_php['title']);

$ip GALLERY_ADMIN_MODE '
        <tr>
                <td>
                        <input type="checkbox" name="pic_raw_ip" class="checkbox" id="pic_raw_ip" /><label for="pic_raw_ip" class="clickable_option">'
.$lang_search_php['ip_address'].'</label>
                </td>
        </tr>' 
:
        
'<tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
        </tr>'
;

$customs '';

$result cpg_db_query("SELECT * FROM {$CONFIG['TABLE_CONFIG']} WHERE name LIKE 'user_field%_name' AND value <> '' ORDER BY name ASC");

while (
$row mysql_fetch_assoc($result)){
        
$name str_replace(array('_field''_name'), ''$row['name']);
        
$customs .= <<< EOT
             <tr>
                        <td><input type="checkbox" name="
$name" id="$name" class="checkbox" /><label for="$name" class="clickable_option">{$row['value']}</label></td>
                </tr>
EOT;
}
echo <<< EOT
        <tr>
            <td class="tableb" align="center" >
                <input type="text" style="width: 80%" name="search" maxlength="255" value="" class="textinput" />
                <input type="submit" value="
{$lang_search_php['submit_search']}" class="button" />
                <input type="hidden" name="album" value="search" />
            </td>
        </tr>
                <tr>


  <table align="center">
                                        <tr>
                                          <td><input type="checkbox" name="filename" id="filename" class="checkbox" checked="checked"/>
                                          <label for="filename" class="clickable_option">
{$lang_adv_opts['filename']}</label></td>
                                                <td><input type="checkbox" name="title" id="title" class="checkbox" checked="checked" />
                                                <label for="title" class="clickable_option">
{$lang_adv_opts['title']}</label></td>
                                                <td><span class="clickable_option">
                                                  <input type="checkbox" name="caption" id="caption" class="checkbox" checked="checked" />
{$lang_adv_opts['caption']}</span></td>
                                                <td><input type="checkbox" name="keywords" id="keywords" class="checkbox" checked="checked" />
                                                  <label for="keywords" class="clickable_option">
{$lang_adv_opts['keywords']}</label></td>
                                          <td><label for="keywords" class="clickable_option">
                                            <select name="type" class="listbox">
                                              <option value="AND" selected="selected">
{$lang_search_php['all_words']}</option>
                                              <option value="OR">
{$lang_search_php['any_words']}</option>
                                            </select>
                                          </label></td>
                                        </tr>
                                                
                                </table>




                        </td>
                </tr>
EOT;


endtable();
echo 
'</form>';

echo <<< EOT
      <script language="javascript" type="text/javascript">
      <!--
      document.searchcpg.search.focus();
      -->
      </script>
EOT;


ob_end_flush();
?>


<?php
endtable
();

?>


Joachim Müller

Add your search box to the template.html file of your theme - that would be wiser. No need for custom queries - just add the HTML output of the regular search box. The line $ip = GALLERY_ADMIN_MODE ? 'is nonsene imo.

mooxe

Thanks I'll try that.


(I am PHP cut-paste-reload-repeat programmer)

Joachim Müller

This is the HTML you need to paste in:<form method="post" action="thumbnails.php" name="searchcpg">
<!-- Start standard table -->
<table align="center" width="60%" cellspacing="1" cellpadding="0" class="maintable">
        <tr>
                <td class="tableh1" colspan="1">Search the file collection</td>

        </tr>
        <tr>
            <td class="tableb" align="center" >
                <input type="text" style="width: 80%" name="search" maxlength="255" value="" class="textinput" />
                <input type="submit" value="search" class="button" />
                <input type="hidden" name="album" value="search" />
            </td>
        </tr>
                <tr>

                        <td class="tableb">
                                <table align="center" width="60%">
                                        <tr>
                                                <td>Search in:</td>
                                                <td align="center">Age:</td>
                                        </tr>
                                        <tr>
                                                <td><input type="checkbox" name="title" id="title" class="checkbox" checked="checked" /><label for="title" class="clickable_option">Title</label></td>

                                                <td align="right">Newer than <input type="text" name="newer_than" size="3" maxlength="4" class="textinput" /> days</td>
                                        </tr>
                                        <tr>
                                                <td><input type="checkbox" name="caption" id="caption" class="checkbox" checked="checked" /><label for="caption" class="clickable_option">Caption</label></td>
                                                <td align="right">Older than <input type="text" name="older_than" size="3" maxlength="4" class="textinput" /> days</td>

                                        </tr>
                                        <tr>
                                                <td><input type="checkbox" name="keywords" id="keywords" class="checkbox" checked="checked" /><label for="keywords" class="clickable_option">Keywords</label></td>
                                                <td>&nbsp;</td>

                                        </tr>
                                        <tr>
                                                <td><input type="checkbox" name="owner_name" id="owner_name" class="checkbox" /><label for="owner_name" class="clickable_option">Owner name</label></td>

                                                <td align="right"><select name="type" class="listbox">
                                                        <option value="AND" selected="selected">Match all words (AND)</option>
                                                        <option value="OR">Match any words (OR)</option></select>
                                                </td>
                                        </tr>
                                        <tr>
                                                <td><input type="checkbox" name="filename" id="filename" class="checkbox" /><label for="filename" class="clickable_option">Filename</label></td>

                                                <td>&nbsp;</td>
                                        </tr>
                                                                <tr>
                        <td><input type="checkbox" name="user1" id="user1" class="checkbox" /><label for="user1" class="clickable_option">Custom field for image description 1</label></td>
                </tr>
                                                <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>

        </tr>
                                </table>
                        </td>
                </tr></table>
<!-- End standard table -->
</form>
If you're feeling adventurous, replace the hard-coded text with the corresponding language file strings. If you're feeling even more adventurous, add an if/then switch that hides the search form output on the actual search page (search.php). If you don't want the options to show, change the type for the corresponding field from checkbox to hidden. Has been discussed often already, please use the search.

mooxe

Thanks Joachim.... I ended up with this before you posted what you had... A bit messy but was getting there.

<form method="post" action="thumbnails.php" name="searchcpg">
  <tr>
    <td class="tableb" align="center" ><input type="text" style="width: 80%" name="search" maxlength="255" value="" class="textinput" />
      <input type="submit" value="{$lang_search_php['submit_search']}" class="button" />
      <input type="hidden" name="album" value="search" />
    </td>
  </tr>
  <tr>
    <table align="center">
      <tr>
        <td><input type="checkbox" name="filename" id="filename" class="checkbox" checked="checked"/>
          <label for="filename" class="clickable_option">{$lang_adv_opts['filename']}</label></td>
        <td><input type="checkbox" name="title" id="title" class="checkbox" checked="checked" />
          <label for="title" class="clickable_option">{$lang_adv_opts['title']}</label></td>
        <td><span class="clickable_option">
          <input type="checkbox" name="caption" id="caption" class="checkbox" checked="checked" />
          {$lang_adv_opts['caption']}</span></td>
        <td><input type="checkbox" name="keywords" id="keywords" class="checkbox" checked="checked" />
          <label for="keywords" class="clickable_option">{$lang_adv_opts['keywords']}</label></td>
        <td><label for="keywords" class="clickable_option">
          <select name="type" class="listbox">
            <option value="AND" selected="selected">{$lang_search_php['all_words']}</option>
            <option value="OR">{$lang_search_php['any_words']}</option>
          </select>
          </label></td>
      </tr>
    </table>
    </td>
  </tr>

</form>

mooxe

Ok now I remember why I didnt want to use template.html. My search query on the mainpage was just for quickie search, a user lands on my page and is looking for something right away, he can do it through anycontent.php. I dont want the seach on the top of every page. Using your same code I should be able to just put that in anycontent.php anyways and it would just what I planned.

Joachim Müller

Yes: if you plan to apply a condition (e.g. only displaying the search form on particular pages or for particular users), your code can't go into template.html, but needs to go into a PHP-driven page. It's a matter of taste wether to use anycontent.php or theme.php.
Issue solved?

mooxe