Jump to content
TNG Community

****SOLVED**** admin_media.php


Jan Bastiaanssen

Recommended Posts

Jan Bastiaanssen

Using admin_media.php, I get  the standard report.

I would like a extra column Owner/Source  between Linked to and  Last modified.

Is that posssible;    if yes how can i realize that.

 

Thanks,

Jan

Screenshot_2.jpg

Link to comment
Share on other sites

Michel KIRSCH

Jan,

to make what you want, you must do 3 things :

1) modify the $query to "import" the owner from the table

2) Add a column and it's title to the table

3) insert the data imported in the new column

In admin_media.php :

1) Modifying the $query :

modify this block :

$query = "SELECT $media_table.mediaID as mediaID, $medialinkID description, notes, path, thumbpath, mediatypeID, abspath, mediakey, usecollfolder, $media_table.gedcom, form, changedby, DATE_FORMAT(changedate,\"%d %b %Y\") as changedatef
	FROM $media_table $join $wherestr
	ORDER BY $orderstr LIMIT $newoffset" . $maxsearchresults;

in :

$query = "SELECT $media_table.mediaID as mediaID, $medialinkID description, notes, owner, path, thumbpath, mediatypeID, abspath, mediakey, usecollfolder, $media_table.gedcom, form, changedby, DATE_FORMAT(changedate,\"%d %b %Y\") as changedatef
    FROM $media_table $join $wherestr
    ORDER BY $orderstr LIMIT $newoffset" . $maxsearchresults;

2) Add a column : After this line,

			<td class="fieldnameback fieldname"><nobr> <b><?php echo $admtext['linkedto']; ?></b> </nobr></td>

insert :

			<td class="fieldnameback fieldname"><nobr>&nbsp;<b><?php echo "Your column name here"; ?></b>&nbsp;</nobr></td>

 

3) add the data : after this block :

			$medialinktext = $medialinktext ? "<ul>\n$medialinktext\n</ul>\n" : "&nbsp;";
			echo "<td nowrap class=\"lightback normal\" valign=\"top\">$medialinktext</td>\n";

Add this line :

			echo "<td nowrap class=\"lightback normal\" valign=\"top\">{$row['owner']}</td>\n";

Tested. Don't forget to make it permanent with a Mod !

Michel

Link to comment
Share on other sites

Jan Bastiaanssen

Michel,

I followed your lines and that worked like a charm.

THANKS A LOT.

For maintenance reasons I tried to  make that column selectable bit that is not realy work.

Do you have  time to look at it ?

Attached is the  cfg-file.

 

Screenshot_1.jpg

Xtra Media Column.cfg

Link to comment
Share on other sites

Michel KIRSCH

Jan, the mod can not install because your location 1 already contains the ", owner" field !

 

Link to comment
Share on other sites

Michel KIRSCH

To make the check box functionning, you must

1 - define the $admtext['noowner'] in your customconfig.php file (best is a $text['noowner'] = "Geen eigenaar"; in $text and not in $admtext)

2.- when the box is checked, you have to modify the sql string with

if($noowner){
    $wherestr .= $wherestr ? " AND owner = \"\"" : "owner = \"\"";
}    

after

if( $nothumb ) {
    $wherestr .= $wherestr ? " AND thumbpath = \"\"" : "thumbpath = \"\"";
}

Not tested but i think it will works...

Michel

PS : to have more facility to retrieve your modified code, please indicate it with a string like "// Xtra column Mod "

Replacing the entire $query string is not a good practice : if another mod must work on the same part, it cannot install after your mod and vice-versa.

The best is to look if your owner field is not already in the $query string and if not, add it.

if (!stristr(", owner", $query))
   $query = str_replace("notes, ","notes, owner, ",$query);

 

 

Link to comment
Share on other sites

Michel KIRSCH

What's the error Jan?

I've tested my version : it runs fine...

Send me your admin_media.php file. I think there are some code snippets staying in it

or replace your admin_media.php with a fresh version (be sure that no others mods are modifying it !)

Michel

Link to comment
Share on other sites

Michel KIRSCH

I find youe error :

you will replace the $query striing, but you indicate

$query = "SELECT $media_table.mediaID as mediaID, $medialinkID description, notes, path, thumbpath, mediatypeID, abspath, mediakey, usecollfolder, $media_table.gedcom, form, changedby, DATE_FORMAT(changedate,\"%d %b %Y\") as changedatef


this is not the entire query...

Link to comment
Share on other sites

Michel KIRSCH

and the second error is :

if($noowner){
    $wherestr .= $wherestr ? " AND noowner = \"\"" : "noowner = \"\"";
}

but the field noowner doesn't exists in the table.

The field name is owner. noowner is the name of your field on the screen(the checkbox)

so :

if($noowner){
    $wherestr .= $wherestr ? " AND owner = \"\"" : "owner = \"\"";
}

Link to comment
Share on other sites

Michel KIRSCH
8 hours ago, Rob Severijns said:

I'm interested in the working cfg file too

Rob, do you try my version?

Link to comment
Share on other sites

Michel KIRSCH
2 minutes ago, Rob Severijns said:

Yes, I have installed it.

Thx.

Michel

Link to comment
Share on other sites

Jan Bastiaanssen

Michel,

I don't know what i did wrong, but your version works like a charme now.

Thanks very much.

Jan

Link to comment
Share on other sites

Jan Bastiaanssen

Michel & Rob,

For your interest:

Xtra Media Column V13.0.3.1.cfg is not working together with admin_media_search V13.0.0.14d.cfg from Robin Richmond.

So we have to choose.

Jan

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...