+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: Export PDF plugin: how to add a couple of listing fields only

  1. #1
    Senior Member
    Join Date
    Sep 2019
    Location
    Australia mate.
    Posts
    164

    Export PDF plugin: how to add a couple of listing fields only

    I'm attempting to modify the Export PDF plugin to export a very simplified version of the listing details. It will result in a small single page flyer type of printable ad instead rather than a multiple page PDF.

    Basically all I need to include is my logo, QR Code and a few basic fields such as Seller, title, phone, email, price and a couple of listing fields I have added to my site. I'll be deleting the rest of the code for the items that I don't need.

    I'm using the realty package if that makes any difference but I'm guessing not.

    Can someone please give me an example of how to add a listing field (let's perhaps use "price" field as an example) to the following list of variables in the code from plugins/PdfExport/PdfExport.inc.php


    Code:
    Only registered members can view the code.
    Thanks in advance guys.

  2. #2
    Senior Member
    Join Date
    Sep 2019
    Location
    Australia mate.
    Posts
    164
    Still looking for some hints on this one please before it drops off the radar.

  3. #3
    Flynax developer Rudi's Avatar
    Join Date
    Dec 2014
    Location
    Planet Earth
    Posts
    3,162
    Hello,

    You should modify html part of the code,

    see // Print listing details code below:

    you can control fields you need to display by their keys:

    from:
    PHP Code:
    Only registered members can view the code
    to:
    PHP Code:
    Only registered members can view the code
    use your field keys instead of YOUR_FIELD_KEY
    Last edited by Rudi; November 6, 2019 at 09:14 AM.

  4. #4
    Senior Member
    Join Date
    Sep 2019
    Location
    Australia mate.
    Posts
    164
    Fantastic Rudi, very much appreciated. I'll give that a try and see how I go. Thanks again.

  5. #5
    Senior Member
    Join Date
    Sep 2019
    Location
    Australia mate.
    Posts
    164
    I tried the method that Rudi mentioned and whilst it does work it is not ideal layout for what I am attempting to produce, at least not with my limited knowledge of how to set out the page using that method. I really wanted to be able to to create a type of small flyer (not much bigger than a business card) with different fields in certain positions and be able to edit the size of the font/italics etc for certain fields individually. Rudi's method displays a list of fields one after the other and I'm unsure on how to customise field placement and individual text attributes for each field attributes further using that method.

    I came up with the following which seems to mostly work however I am having problems with the PDF output of the "phone" field and also the "price" field as the output is unexpected.


    Using the following code the price field outputs for example "295|dollars" when what I want to see is "$295"

    The phone field output results in something like "c:61|a:02|n:1234567" when what I really want to see is "+61 (02) 1234567" (minus quotes of course).

    Is there an easy way to adjust this code below to do what I need? Thanks in advance if anyone can help out.



    Code:
    Only registered members can view the code.

  6. #6
    Flynax developer Rudi's Avatar
    Join Date
    Dec 2014
    Location
    Planet Earth
    Posts
    3,162
    you should access directly the field you need to display via array $listing

    for that find and change the row above:

    PHP Code:
    Only registered members can view the code
    to:
    PHP Code:
    Only registered members can view the code
    specify group_key which this field is related to on the listing form and use the key of your field:

    $listing['GROUP_KEY']['Fields']['FIELD_KEY']['value']


    for example:
    PHP Code:
    Only registered members can view the code

  7. #7
    Senior Member
    Join Date
    Sep 2019
    Location
    Australia mate.
    Posts
    164
    Many thanks Rudi, I'm almost there. Using your code the price field is now showing correctly with the dollar symbol at the front ie: $ 295

    (would rather there be no space between the $ and value ie: $295 but that's a very minor thing).


    I am unable to figure out how to get the "phone" field value to show though using the method you outlined as it's coming up blank on the PDF.

    I don't know what the group_key for "phone" is or how to find that info so I just tried the following group keys and none of them worked.

    I tried

    <td>'. $listing['common']['Fields']['phone']['value'] .'</td>

    and also

    <td>'. $listing['additional_information']['Fields']['phone']['value'] .'</td>

    and also

    <td>'. $listing['location']['Fields']['phone']['value'] .'</td>


    Almost there I think.

  8. #8
    Flynax developer Rudi's Avatar
    Join Date
    Dec 2014
    Location
    Planet Earth
    Posts
    3,162
    forgot to mention:

    if your field is outside field group or you don't use field groups on the listing form

    you should use a prefix like this nogroup_1, nogroup_2,.. etc

    the index depends on the field order

    so if your phone field goes like:

    1. some field (no group)

    2. the group of fields (with group)

    3. your phone field (no group)

    you should access it so:

    $listing['nogroup_3']['Fields']['phone']['value']


    anyway, you can always print $listing array and see correct key using var_dump($listing); exit();



    as for the space in price you can remove it in

    includes > classes > rlCommon.class.php > public function adaptValue > in case 'price':

    change:
    PHP Code:
    Only registered members can view the code
    to:
    PHP Code:
    Only registered members can view the code
    Last edited by Rudi; November 21, 2019 at 12:47 PM.

  9. #9
    Senior Member
    Join Date
    Sep 2019
    Location
    Australia mate.
    Posts
    164
    Thanks Rudi,

    I couldn't get the phone field working with your suggestion as I think you perhaps thought that I had created the phone field myself? when actually it's just the default phone field that comes with the Realty install.

    So, I tried the following code after some trial and error and it works and displays the phone number with the + symbol and brackets () around the area code. Yay! Funny how I get excited about small advances

    '. $seller['Fields']['phone']['value'] .'

    The only thing that looks a little screwy now in the phone number is the hyphen after the first 3 digits. Is there a way to remove the hyphen completely and/or adjust it's position so it is after the 4th digit?


    Edit: Regarding the space after currency symbol, I just had a look for includes > classes > rlCommon.inc.php
    It seems that file name doesn't exist with 4.7.2

    However I think the correct file name is below as this contains the code you referred to:
    includes > classes > rlCommon.class.php
    Last edited by Graham Jupp; November 21, 2019 at 12:29 PM.

  10. #10
    Flynax developer Rudi's Avatar
    Join Date
    Dec 2014
    Location
    Planet Earth
    Posts
    3,162
    yes, it was a typo, the file is rlCommon.class.php

    regarding the phone format: see this thread: https://forum.flynax.com/showthread....light=reefless

    to remove the hyphen

    change:
    PHP Code:
    Only registered members can view the code
    to

    PHP Code:
    Only registered members can view the code
    or use:
    PHP Code:
    Only registered members can view the code
    to put it after 4th digit

+ Reply to Thread