1. NOTICE: If you are using Fabrik and update to Joomla 3.10, you will need to update to Fabrik 3.10. And, if you are using Fabrik, do not upgrade to Joomla 4, we do not have a supported version ready for release. More information on a release date coming soon. Also, please note that Fabrik 3.10 will not install on any Joomla sites less than 3.8.
    Dismiss Notice

different lists in the same template

Discussion in 'Community' started by germanoalves, Jul 9, 2021.

  1. germanoalves

    germanoalves Member

    Level: Community
    Helo!
    I'm building a template for a stripe (let's call it list A) and pdf of that list.

    I have another table (let's call table B) and I would like to get some fields from this other table to compose the template of table A.

    Would it be possible?

    If so, how would I do it?

    Thanks!
     
  2. juuser

    juuser Well-Known Member

    Level: Community
    Join table B to table A and you'll have all the elements available from the table B for your PDF-creation.
     
  3. germanoalves

    germanoalves Member

    Level: Community
    Understand. I will test here and return with results. Thank you friend @juuser !
     
  4. germanoalves

    germanoalves Member

    Level: Community
    did not work @juuser

    Other fields ended up joining... the form of B appeared in the form of A....

    Wouldn't there be a way for me to get just one field from another table via php for example? Because I only need this information in the pdf template and not in the list or form?

    Thanks!
     
  5. lousyfool

    lousyfool Active Member

    Level: Community
    Sure. You can write your own DB query in a custom PDF template.

    Or alternatively, involving multiple steps, you could
    - create a copy of your original list A
    - join list B with this copy
    - in the backend listing of elements, disable the list B elements from being displayed in the list except the one you want to show
    - then base your PDF on this list copy (while elsewhere you keep using the original, "unjoined" lists and forms)
     
    juuser likes this.
  6. juuser

    juuser Well-Known Member

    Level: Community
    ...or you can use calc element in your list A to get any value from list B. Just make sure "Only calc on save" is set to "Yes". And you need to update the calc element field for already existing rows in your list A either by editing and saving the record or with larger amount of rows it's reasonable to use e.g. PhpMyAdmin.
     
  7. germanoalves

    germanoalves Member

    Level: Community
    thanks @lousyfool and @juuser!
    I will test the answers and come back with the results!
     
  8. germanoalves

    germanoalves Member

    Level: Community
    did not work @lousyfool :(
    Because in the "Copy" list it doesn't store anything, as it's a copy, it throws everything to the "A-list"
    And list A doesn't have the elements I need from "table B". And in the "copy list" I can't generate the pdf with the contents, because everything is being saved in the "A list".

    @juuser to use the calc element, I would have to use
    "return {'table_complete_element_name'} ?
     
  9. juuser

    juuser Well-Known Member

    Level: Community
    I don't know what problem you have with lousyfool's suggestion, but when you want to get element data from another table which is not joined to your main table, you cannot use placeholders.

    In calc element you have to use something like:
    Code (Text):
    $mydb = JFactory::getDBO();
    $mydb->setQuery("SELECT b.myfield FROM tableA AS a LEFT JOIN tableB AS b ON a.id = b.tableb___join_element WHERE a.id = '{rowid}' ");
    return $mydb->loadResult();
     
  10. germanoalves

    germanoalves Member

    Level: Community
    thanks @juuser!
    I will test the answers and come back with the results!
     
  11. germanoalves

    germanoalves Member

    Level: Community
    Hey
    partially managed to resolve @juuser and @lousyfool

    I joined table B with a copy of table A, this copy is called 'copy A'

    Now I have another problem:

    I have in table B records made by each user. I need that in the tablema 'copy A' appear in a field only the records that the corresponding user made in table B, in isolation, each one seeing only what itself registered in list B.

    Could I do this natively?

    Thanks!
    upload_2021-7-19_23-17-37.png
     
  12. juuser

    juuser Well-Known Member

    Level: Community
  13. germanoalves

    germanoalves Member

    Level: Community

Share This Page