( Currently Supported PDF and Text file )
- Make a directory called “doc” within the “custom” folder (rights: 777).
- Make a php file called “showfile.php” (rights: 777) in the “prudento” folder.
- Place the following code within showfile.php:
for all doc:::::
<?php$FileNaam=$_GET['file'];
$FileType=$_GET['type'];
$base = str_replace(‘/custom/doc/showfile.php’, ” ,$_SERVER['PHP_SELF'] );
echo ‘<body scroll=”no” style=”overflow:hide; height:480px;”>’;
echo ‘<div id=”bg_image” style=”position:absolute; top:0px; left:0px; height:100%; width:100%”>’;
echo ‘<embed src=”http://docs.google.com/gview?url=http://’ . $_SERVER['SERVER_NAME'] . $base . ‘/cache/upload/’. $FileNaam .’&embedded=true “id=”application/pdf” width=”100%” height=”480px” ></embed >’;
echo ‘</div>’;
?>
for pdf and text exclude doc::::::::
<?php
$FileNaam=$_GET['file'];
$FileType=$_GET['type'];
/************************************
* find root of the sugarinstallation
************************************/
$base = str_replace(‘/custom/doc/showfile.php’, ” ,$_SERVER['PHP_SELF'] );
/************************************
* build html page to show in iframe field
************************************/
/************************************
* build html page to show in iframe field
************************************/
echo ‘<body scroll=”no” style=”overflow:hidden; height:100%;”>’;
echo ‘<div id=”bg_image” style=”position:absolute; top:0px; left:0px; height:100%; width:100%”>’;
echo ‘<embed src=”http://’ . $_SERVER['SERVER_NAME'] . $base . ‘/cache/upload/’. $FileNaam .’” id=”imgPhoto” width=”100%” height=”100%” ></embed >’;
echo ‘</div>’;
?>
Go to studio=>documents=>fields an make a costum field with these properties:
- Datatype: Iframe
- Field label: Preview
- Generate URL: Yes
- Standard value: http://domain.com/custom/doc/showfile.php?file={document_revision_id}
- Maximun size: 225
- Iframe height: 500
- Save
- Go to studio=>documents=>layout=>detailview and make a panel called something like “preview”
- Place the “preview” block on the new panel and make it fit the whole line.
- Do a quick repair in the admin menu
- Open the .htaccess (if any) in the sugar root folder.
- Comment out or delete the 2 rows with the cache and temp folder ( otherwise Googledocs cant access the files)
5 comments:
Does this work on 6.5.13 Community edition? BTW shouldn't the second line be:
Make a .php file called “showfile.php” (rights: 777) in the “doc” folder.
and in the code:
$base = str_replace(‘/custom/doc/showfile.php’, ” ,$_SERVER['PHP_SELF'] );
Also I get the file token as duplicate when I assign $FileNaam=$_GET['file']; i.e.
528eb9b0-6415-2450-0d4d-51a5456e297c528eb9b0-6415-2450-0d4d-51a5456e297c
and not
528eb9b0-6415-2450-0d4d-51a5456e297c
Can you help me with this?
Thanks
Dear,
Have you take document_revision_id?
hi,
this code is working fine with pdf docs, but i need to do this for other file types also i.e. for excel(.xlsx) and word (.doc, .docx) files also. I need this urgently. plz let me how to do this.
thanks
I came across this snippet jus now.
Can you please confirm if this is still supposed to work on let's say SuiteCRM or SugarCRM Community edition..?
Please advise...
I have checked with the sugarcrm 5.2 to 6.2 with full working status
Post a Comment