Setting an URL on a Field

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
User avatar
RonP
Veteran Member
Posts: 219
Joined: 2013-08-27 13:36
Location: Heiloo, The Netherlands
Contact:

Setting an URL on a Field

Post by RonP » 2015-02-28 13:49

Hi,

Is there a way to setup an URL on a field?
The case is:
Table Countries and a field named: Flag.
De flag is placed as an image on my server, however I can’t define this field as an "URL type.

Ron

User avatar
RonP
Veteran Member
Posts: 219
Joined: 2013-08-27 13:36
Location: Heiloo, The Netherlands
Contact:

Re: Setting an URL on a Field

Post by RonP » 2015-02-28 15:12

Hi,

Almost there .... :P

By marking the field (Flag) as Rich (HTML) area it is possible to place an URL.
The next step that I actually want is: Navigating from de Pop-Up screen to the desired location on the server (situated in the cloud).
(is it perhaps possible to place a "base address" like:

Code: Select all

http://cloud.domain/Rootdirecory/SubDirectory/
Ron
Attachments
Appgini_Add_Link.PNG
Appgini_Add_Link.PNG (12.84 KiB) Viewed 19312 times

Bertv
Veteran Member
Posts: 65
Joined: 2013-12-11 15:59

Re: Setting an URL on a Field

Post by Bertv » 2015-03-01 14:53

Ron,
I am not sure if you want the same as I
do, but what I do is the following:
definition of the field 'Video' in the table:
AppGini.png
AppGini.png (65.74 KiB) Viewed 19301 times
and the result in the detail form:
helpform.png
helpform.png (159 KiB) Viewed 19301 times
When you have update / insert permissions you can insert the url.
When you have only a read permission, you can only click the icon.

The directpry 'instructions' is a subdirectory of the rootdirectory (same level as the 'hooks' and 'images')

When you click the icon the video starts in a new tab:
AppGini.png
AppGini.png (65.74 KiB) Viewed 19301 times
Success,
Attachments
instru.png
instru.png (88.44 KiB) Viewed 19301 times
Bert
I am using Appgini 5.75

User avatar
RonP
Veteran Member
Posts: 219
Joined: 2013-08-27 13:36
Location: Heiloo, The Netherlands
Contact:

Re: Setting an URL on a Field

Post by RonP » 2015-03-03 10:45

Hi Bertv,
Thanks for your answers.
This could be an option, it works for small files. (I mean not that many pictures)

I'm working with a database with > 80.000 pictures of ships. These pictures are "in the cloud", so on a separate server as the AppGini files. Is it possible to change the name to the name of the cloud server in the Behavior" option?
Ron

User avatar
RonP
Veteran Member
Posts: 219
Joined: 2013-08-27 13:36
Location: Heiloo, The Netherlands
Contact:

Re: Setting an URL on a Field

Post by RonP » 2015-03-09 13:33

Hi There,

Any (more) suggestions?

Ron

scampollo
Posts: 6
Joined: 2014-07-02 16:33

Re: Setting an URL on a Field

Post by scampollo » 2015-03-09 18:35

So would you like to have a base address? maybe you could write some code in the before_insert hook of your table with something like this:

Code: Select all

function myTable_before_insert(&$data, $memberInfo, &$args){

         // Set base address
        $baseAddress = 'http://cloud.domain/Rootdirecory/SubDirectory/';
        //Concatenate with the value given
        $data['myField'] = $baseAddress . $data['myField'];
         
      return TRUE;
}
So everytime you insert a new row you should just put the name of the file in the cloud server and it automatically writes on DB with the full address. Hope this helps or let me know if I'm misunderstanding.

User avatar
RonP
Veteran Member
Posts: 219
Joined: 2013-08-27 13:36
Location: Heiloo, The Netherlands
Contact:

Re: Setting an URL on a Field

Post by RonP » 2015-03-10 16:14

Hi scampoli,
Thanks for your input. It might work however....

If I put this code:

Code: Select all

function landen_before_insert(&$data, $memberInfo, &$args){
         // Set base address
        $baseAddress = 'http://cloud.domain/Rootdirecory/SubDirectory/';
        //Concatenate with the value given
        $data['myField'] = $baseAddress . $data['myField'];
   
	  return TRUE;
	}
Then I don't see any difference. I do something wrong I think.
Do I have to alter a "field" defenition?

Ron
Attachments
Land_1.PNG
Back End
Land_1.PNG (173.16 KiB) Viewed 19211 times
Land.PNG
Front End
Land.PNG (27.22 KiB) Viewed 19211 times

scampollo
Posts: 6
Joined: 2014-07-02 16:33

Re: Setting an URL on a Field

Post by scampollo » 2015-03-10 20:00

I think you should replace this line

Code: Select all

$data['myField'] = $baseAddress . $data['myField'];
with the name of your field, something like this:

Code: Select all

$data['Vlag'] = $baseAddress . $data['Vlag];

User avatar
RonP
Veteran Member
Posts: 219
Joined: 2013-08-27 13:36
Location: Heiloo, The Netherlands
Contact:

Re: Setting an URL on a Field

Post by RonP » 2015-03-11 08:48

Hi scampollo.
That was stupid of me, sorry. :mrgreen:

I've changed it but the result is still the same.

The URL is not set, I still have to type it.
Hereby the generated HTML-code. (This is the code after I've opened the "link" attribute.

Code: Select all

<div class="form-group">
					<label for="Vlag" class="control-label col-lg-3">Vlag</label>
					<div class="col-lg-9">
						
						<p class="form-control-static">
							<a id="Vlag-link" href="link.php?t=landen&f=Vlag&i=99" target="_blank"></a>
							<label for="Vlag"><button type="button" id="Vlag-edit-link" class="btn btn-default hspacer-lg vspacer-sm" data-toggle="collapse" data-target="#Vlag" title="Wijzigen"><i class="glyphicon glyphicon-pencil"></i></button></label>
						</p>

Ron

patsd102
Veteran Member
Posts: 142
Joined: 2013-01-15 19:59

Re: Setting an URL on a Field

Post by patsd102 » 2015-03-14 21:02

Try this in your TempleTV.html file

<td id="your-table-<%%VALUE(yourtable)%%>" class="field_log-Name "><a href="http://www.your url php?=<%%VALUE(table)%%>" target="_blank"><%%VALUE(table)%%></a></td>

(Make sure to back up your file first)
23.17

User avatar
RonP
Veteran Member
Posts: 219
Joined: 2013-08-27 13:36
Location: Heiloo, The Netherlands
Contact:

Re: Setting an URL on a Field

Post by RonP » 2015-03-19 11:52

Hi patsd102,
Sorry for reacting so late, I've missed your mail or so.

I've put your suggested code into the file.
Hower, now resulst. Did I put it at the rigth place? Did I substitute the rigth names.
My knowledge of PHP is verry poor :(

The table is named: Landen and the field is landen.vlag.
The code is: (see first line)

Code: Select all

		<td id="landen<%%VALUE(landen)%%>" class="field_log-Name "><a href="http://cloud.domain/Rootdirecory/SubDirectory/ php?=<%%VALUE(table)%%>" target="_blank"><%%VALUE(table)%%></a></td>
		<td id="landen-Land-<%%VALUE(LandenID)%%>" class="landen-Land "><%%SELECT%%><%%VALUE(Land)%%><%%ENDSELECT%%></td>
		<td id="landen-Vlag-<%%VALUE(LandenID)%%>" class="landen-Vlag "><a href="link.php?t=landen&f=Vlag&i=<%%VALUE(LandenID)%%>" target="_blank"><%%VALUE(Vlag)%%></a></td>
		<td id="landen-Mutator-<%%VALUE(LandenID)%%>" class="landen-Mutator "><%%VALUE(Mutator)%%></td>
		<td id="landen-Mutatiedatum-<%%VALUE(LandenID)%%>" class="landen-Mutatiedatum "><%%VALUE(Mutatiedatum)%%></td>
		<script>jQuery(function(){ var e_Vlag='<%%VALUE(Vlag)%%>'; if(e_Vlag=='' || e_Vlag=='&nbsp;') jQuery('#landen-Vlag-<%%VALUE(LandenID)%%>').html(''); });</script>

patsd102
Veteran Member
Posts: 142
Joined: 2013-01-15 19:59

Re: Setting an URL on a Field

Post by patsd102 » 2015-03-20 15:54

.php?flag=

try this,, to call up your field on your cloud.
23.17

User avatar
RonP
Veteran Member
Posts: 219
Joined: 2013-08-27 13:36
Location: Heiloo, The Netherlands
Contact:

Re: Setting an URL on a Field

Post by RonP » 2015-03-20 16:39

Hi patsd1102

The code is now: ( You gave: Flag, however the fieldname is : vlag (dutch for Flag)

Code: Select all

<td id="landen<%%VALUE(landen)%%>" class="field_log-Name "><a href="http://cloud.domain/Rootdirecory/SubDirectory/ .php?landen.vlag=<%%VALUE(table)%%>" target="_blank"><%%VALUE(table)%%></a></td>
I don't see any change.

Is the code on the right place, is the line at the right place? (It is now the first line)

Ron
Attachments
App.PNG
App.PNG (36.53 KiB) Viewed 19119 times

patsd102
Veteran Member
Posts: 142
Joined: 2013-01-15 19:59

Re: Setting an URL on a Field

Post by patsd102 » 2015-03-20 22:29

Have you an example of a uri you want to connect to,
http://cloud.domain/Rootdirecory/SubDirectory / mylink.html ?
23.17

User avatar
RonP
Veteran Member
Posts: 219
Joined: 2013-08-27 13:36
Location: Heiloo, The Netherlands
Contact:

Re: Setting an URL on a Field

Post by RonP » 2015-03-21 10:27

Hello Patssd102,

For one reason I don't receive mails anymore after a response on a post. I have to ask why.

The "try example" is about Flags from Countries.
The main goal is to have an url build for Photos from ships, like this example:
However, the example url:
http://cloud.kraalmedia.nl/Shipphoto/Sh ... %20(1).jpg

What I realy like to have is:
Base address: http://cloud.kraalmedia.nl/Shipphoto/Ship/
Variable name photographer = name of the Photographer (Keizer)
Variable name alphabet = subdirectory (V)
Variable name minmax = subdirectory (min or max)
Variable name picture= filename (Verona%20Ridderkerk%20(1).jpg

Ron

Bertv
Veteran Member
Posts: 65
Joined: 2013-12-11 15:59

Re: Setting an URL on a Field

Post by Bertv » 2015-03-21 17:55

Ron,
is this what you want as table view:
table_view.png
table_view.png (75.1 KiB) Viewed 19100 times
and this as detail view:
detail_view.png
detail_view.png (51.06 KiB) Viewed 19100 times
In this example are only tw fields for the link of the picture (url address and name picture).

- create the fields for the url adress, picture name and the picture as varchar fields. Define the picture as an image.
appGini_fielddetails.png
appGini_fielddetails.png (125.7 KiB) Viewed 19100 times
After generating:
- add some code in the after-insert and after-update hook for inserting the full link to the picture into the table field of the picture:
hook_after_update.png
hook_after_update.png (12.8 KiB) Viewed 19100 times
- change the tablename_templateDVand TV files; remove the <%%TRANSLATION(ImageFolder)%%>
Below the templateDV, but do the same in the TV template file
templateDVhtml.png
templateDVhtml.png (13.01 KiB) Viewed 19100 times
- make a change in the thumbnail.php script. This script looks at the image-folder and create thumbnails if it is there.
In this case we don't want it. Add the code below after row 20 ($i=$_GET['i']; // original image file name)

// extra code for show picture in link
if(substr(strtoupper($i),0,5)=='HTTP:'){
$i=str_replace(' ', '%20', $i);
getImage($i);
exit;
}

Success,
Bert
I am using Appgini 5.75

User avatar
RonP
Veteran Member
Posts: 219
Joined: 2013-08-27 13:36
Location: Heiloo, The Netherlands
Contact:

Re: Setting an URL on a Field

Post by RonP » 2015-03-21 18:15

Hi bertv,

This is impressive, I'll look in to it and let you know, tomorrow, what your result brings me.

Ik heb het idee dat je Nederlander bent, kunnen we anders eens telefonisch verder kijken als het niet mocht lukken?
Ron

User avatar
RonP
Veteran Member
Posts: 219
Joined: 2013-08-27 13:36
Location: Heiloo, The Netherlands
Contact:

Re: Setting an URL on a Field

Post by RonP » 2015-04-18 11:11

The given solution from Bertv was impressive and works, however it still is a lot of typing an url, every time you have to place a photo.
I can't figure out why the given solution of Patssd102 still doesn't work. It should work but I still not get a "base url" back, so what do I wrong.
I like to "set" the weblink address to a specific URL., where can I do this?



I've changed the landen_templateTV file, see code

Code: Select all

<!-- Edit this file to change the layout of each record in the table view -->
<!-- To disable clicking of a field, remove the <%%select%%> and <%%endselect%%> formatters around it-->

<!-- If you wish to hide the table view header that contains the column titles, -->
<!-- open the generated 'landen_view.php' file in your text editor and -->
<!-- change the value of $x->ShowTableHeader to 0 -->
<td id="landen-<%%VALUE(landen)%%>" class="field_log-Name "><a href="http://cloud.kraalmedia.nl/Shipphoto/Ship/Vlaggen/ .php?=<%%VALUE(table)%%>" target="_blank"><%%VALUE(table)%%></a></td>
		
		<td id="landen-land-<%%VALUE(landenid)%%>" class="landen-land "><%%SELECT%%><%%VALUE(land)%%><%%ENDSELECT%%></td>
		<td id="landen-vlag-<%%VALUE(landenid)%%>" class="landen-vlag "><a href="<%%TRANSLATION(ImageFolder)%%><%%VALUE(vlag)%%>" rel="lightbox"><img src="thumbnail.php?i=<%%VALUE(vlag)%%>&t=landen&f=vlag&v=tv" class="img-thumbnail"></a></td>
		<td id="landen-mutator-<%%VALUE(landenid)%%>" class="landen-mutator "><%%VALUE(mutator)%%></td>
		<td id="landen-mutatiedatum-<%%VALUE(landenid)%%>" class="landen-mutatiedatum "><%%VALUE(mutatiedatum)%%></td>
		<script>jQuery(function(){ var e_vlag='<%%VALUE(vlag)%%>'; if(e_vlag=='' || e_vlag=='&nbsp;') jQuery('#landen-vlag-<%%VALUE(landenid)%%>').html(''); });</script>
I also changed, in landen.php

Code: Select all

	function landen_before_insert(&$data, $memberInfo, &$args){
 // Set base address
        $baseAddress = 'http://cloud.kraalmedia.nl/Shipphoto/Ship/Nl/I/im/';
        //Concatenate with the value given
        $data['vlag'] = $baseAddress . $data['vlag'];
		return TRUE;
So what do I miss

Ron
Appgini-add-link-vlag.PNG
Appgini-add-link-vlag.PNG (8.59 KiB) Viewed 18939 times
Appgini-def-landen-vlag.PNG
Appgini-def-landen-vlag.PNG (81 KiB) Viewed 18939 times

patsd102
Veteran Member
Posts: 142
Joined: 2013-01-15 19:59

Re: Setting an URL on a Field

Post by patsd102 » 2015-04-19 13:29

Would it not be easier to upload the flags to your server via your appgini page.
I use this page where I have 351 images loaded with search set to view the Country column.


http://prefixlist.dx27.net/dx27prefixlist_view.php
23.17

User avatar
RonP
Veteran Member
Posts: 219
Joined: 2013-08-27 13:36
Location: Heiloo, The Netherlands
Contact:

Re: Setting an URL on a Field

Post by RonP » 2015-04-19 14:28

Yes, for the flags it will do. However his table is one of many. My Appgini project is about ships and photo's of them.
Right now there are 80.000 photo's to be displayed, using an Access database and shown by in ASP .
Look or an example: http://www.shipphoto.nl

So....if possible, I still want a solution.
Ron

patsd102
Veteran Member
Posts: 142
Joined: 2013-01-15 19:59

Re: Setting an URL on a Field

Post by patsd102 » 2015-04-19 20:04

80,000 images. Thats a lot of images.
The URL was to link to each image,,

Sorry, I can't help further.
23.17

User avatar
RonP
Veteran Member
Posts: 219
Joined: 2013-08-27 13:36
Location: Heiloo, The Netherlands
Contact:

Re: Setting an URL on a Field

Post by RonP » 2015-04-20 08:18

Hello Patssd102,

Thanks for trying to give me support / solutions.
Maybe someone else give me the solution.

Ron

yvonnes
Posts: 5
Joined: 2015-04-06 17:44

Re: Setting an URL on a Field

Post by yvonnes » 2015-05-08 15:10

Hi Ron,

In my application, I needed to append the primary key of each record to a base URL and I wanted to be able to easily and instantly change the base URL (for example, this week I needed to change the url link for all records from 'http' to 'https'.) I also needed to be able to access this link from other places, not just the AppGini-generated application.

I created a MySQL View (similar to a Query in Access, I think) to build the link by concatenating the base url as a string to the primary key of the current record as a variable (you would probably use the image file name to complete the url in your application.)

After I had the link working properly for each record from the MySQL View results, I added the View as a table in AppGini with all fields set to read-only, and set the link behavior options for field that contained the calculated URL to be a Weblink that displayed the link as contents of another field, and finally linked that view/table as a child table linked by the primary key.

Once the view worked correctly in MySQL to build the complete link, there wasn't really anything special to do in AppGini - I just worked with it as if it was a regular table.

I'm not sure whether you can import queries from Access into AppGini as a table like you can with MySQL Views. If so, maybe a similar approach would work for you.

User avatar
RonP
Veteran Member
Posts: 219
Joined: 2013-08-27 13:36
Location: Heiloo, The Netherlands
Contact:

Re: Setting an URL on a Field

Post by RonP » 2015-05-12 08:29

Hello Yvonnes,

Thanks for the suggestion. I'll try your approach.
Sorry for the late response, I was "out of the office" Later this week I'll work on your suggestion.

Ron

Post Reply