This topic is locked

Long field - more

10/25/2007 3:08:31 PM
PHPRunner General questions
O
osluk author

Instead of the link to a popup page I want to link in the read more link to the detail view form.

Is this possible.
Thanks
Chris

Sergey Kornilov admin 10/26/2007

Don't use Truncate large text fields option. Set View as type of this field to Custom. Write the code that checks the field length and display More link that points to the View page.

O
osluk author 10/26/2007

Thanks Sergey I have searched for a similar bit of code and not found any.

Is there an example anywhere I can learn from.

Thanks Chris

Don't use Truncate large text fields option. Set View as type of this field to Custom. Write the code that checks the field length and display More link that points to the View page.

J
Jane 10/26/2007

Chris,
here is a sample code:

global $data;

if (strlen($value)>10)

$value = substr($value,0,10)." <a href=\"TableName_view.php?editid1=".$data["IDField"]."\">More...</a>";

O
osluk author 10/26/2007

That is exactly what I wanted.

Now the detail.
I can open the correct form but without the data see example here:

http://www.bordeauxreport.com/db-2007/view...+Bottle+Note+BR
I get the following:

http://www.bordeauxreport.com/db-2007/view...ew.php?editid1=
It should be:

http://www.bordeauxreport.com/db-2007/view...php?editid1=568
Do I need to add or change something in the snippet below.
Many thanks for the quick and knowledgeable answer

Chris
global $data;

if (strlen($value)>100)

$value = substr($value,0,100)." <a href=\"Wine_Data_view.php?editid1=".$data["IDField"]."\"><b>More...</b></a>";

Chris,

here is a sample code:

Sergey Kornilov admin 10/26/2007

You need to replace IDField with the name of your key column.

O
osluk author 10/26/2007

Jane / Sergey
Just noticed that the custom field is applied in the List and View pages.

Is there a way to apply this only to the List page (I want the field shown in full in the View page).
Thanks again

Chris

O
osluk author 10/26/2007

You need to replace IDField with the name of your key column.


That was it thanks <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=22637&image=1&table=forumreplies' class='bbc_emoticon' alt=':rolleyes:' /> work great now.
Just need to have the field in full in View, short link in List.
Cheers Chris

J
Jane 10/30/2007

Chris,
try to use this code:

global $data;

if (strlen($value)>100 && !@$_REQUEST["editid1"])

$value = substr($value,0,100)." <a href=\"Wine_Data_view.php?editid1=".$data["IDField"]."\"><b>More...</b></a>";

O
osluk author 10/30/2007

That is perfect
my exact code

global $data;

if (strlen($value)>100 && !@$_REQUEST["editid1"])

$value = substr($value,0,100)." <a href=\"Wine_Data_view.php?editid1=".$data["Ref"]."\"><b>More...</b></a>";


Will add a summary and guide for others when fully tested.

Thanks again
Chris

Chris,

try to use this code:

O
osluk author 10/30/2007
global $data;

if (strlen($value)>180 && !@$_REQUEST["editid1"])

$value = substr($value,0,180)." <a href=\"Wine_Data_view.php?editid1=".$data["Ref"]."\"><b>... See Detail Page ...</b></a>";


Jane this is now working great BUT (there always is one isn't there <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=22769&image=1&table=forumreplies' class='bbc_emoticon' alt=';)' /> )
If the 'notes' field is empty or shorter than the 180 chars specified above - how can I display this link anyway.

This allows users to see browse the detail page.
Cheers Chris
Detail page here

http://www.bordeauxreport.com/db-2007/view...php?editid1=211
List page Here

http://www.bordeauxreport.com/db-2007/view...e_Data_list.php
Colour issue now fixed -thanks for that;

We also tried making this link green in this post - any ideas what I need to do differently.

http://www.asprunner.com/forums/index.php?...ic=6650&hl=

J
Jane 10/30/2007

Chris,
to display link to the view page if field is empty use this code:

global $data;

if (strlen($value)>180 && !@$_REQUEST["editid1"])

$value = substr($value,0,180)." <a href=\"Wine_Data_view.php?editid1=".$data["Ref"]."\"><b>... See Detail Page ...</b></a>";

if (!$value)

$value = substr($value,0,180)." <a href=\"Wine_Data_view.php?editid1=".$data["Ref"]."\"><b>... See Detail Page ...</b></a>";

O
osluk author 10/30/2007

Thanks Jane, - a1 support by the way!!
This worked for the truncated field and linked to the page with full details.

BUT on zero lenght entries the link appeared on the Detail page.

I have boldly hacked about and now the link does not appear on the detail page perfect.
Last minor issue is to not truncate and add the link into entries where the length is 179 chars or less.

So a fifty char entry would be shown is full add green link - link to detail page - not show link on detail page.
Cheers Chris

{

global $data;

if (strlen($value)>180 && !@$_REQUEST["editid1"])

$value = substr($value,0,180)." <a href=\"Wine_Data_view.php?editid1=".$data["Ref"]."\"><font color=\"#00FF00\"> ..<b>.. See Details Page ..</b>.. </font></a>";

if (strlen (!$value)>0 && !@$_REQUEST["editid1"])

$value = substr($value,0,180)." <a href=\"Wine_Data_view.php?editid1=".$data["Ref"]."\"><font color=\"#00FF00\"> ..<b>.. See Details Page ..</b>.. </font></a>";

}


Parse error: syntax error, unexpected T_BOOLEAN_AND in /hsphere/local/home/bauduc-dev/bordeauxreport.com/db-2007/view/include/commonfunctions.php on line 389

Chris,

to display link to the view page if field is empty use this code:

J
Jane 10/31/2007

Chris,
try to use this code:

global $data;

if (strlen($value)>180 && !@$_REQUEST["editid1"])

$value = substr($value,0,180)." <a href=\"Wine_Data_view.php?editid1=".$data["Ref"]."\"><font color=\"#00FF00\"> ..<b>.. See Details Page ..</b>.. </font></a>";
if (strlen($value)<181 && !@$_REQUEST["editid1"])

$value = $value." <a href=\"Wine_Data_view.php?editid1=".$data["Ref"]."\"><font color=\"#00FF00\"> ..<b>.. See Details Page ..</b>.. </font></a>";
if (!$value && !@$_REQUEST["editid1"])

$value = substr($value,0,180)." <a href=\"Wine_Data_view.php?editid1=".$data["Ref"]."\"><font color=\"#00FF00\"> ..<b>.. See Details Page ..</b>.. </font></a>";

O
osluk author 11/2/2007

Perfect,
just rechanged the colour and tweaked spacing
This is the finished page


This is the final code

global $data;

if (strlen($value)>180 && !@$_REQUEST["editid1"])

$value = substr($value,0,180)." <a href=\"Wine_Data_view.php?editid1=".$data["Ref"]."\"><font color=\"#008000\">&nbsp;&nbsp;..<b>.. See Details Page ..</b>.. </font></a>";
if (strlen($value)<181 && !@$_REQUEST["editid1"])

$value = $value." <a href=\"Wine_Data_view.php?editid1=".$data["Ref"]."\"><font color=\"#008000\">&nbsp;&nbsp;..<b>.. See Details Page ..</b>.. </font></a>";
if (!$value && !@$_REQUEST["editid1"])

$value = substr($value,0,180)." <a href=\"Wine_Data_view.php?editid1=".$data["Ref"]."\"><font color=\"#008000\">&nbsp;&nbsp;..<b>.. See Details Page ..</b>.. </font></a>";


Many Thanks

Chris