• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

Extending a Joomla component

escrime

New Member
I am experimenting with Fabrik to use it rather like a CCK but to extend a component rather than a Joomla article. I am making some good progress after watching the videos and completing most of them, but would appreciate some advice.

Currently with the component I have to enter repetitive information e.g. dates, titles, names etc as static HTML styled with CSS. This information (or parts of it) are displayed in different parts of the component. It is prone to error and if I want to change the layout I have to do it for each record stored in the component.

What I wish to do with Fabrik is store this information in a table linked to the respective component record. I should then be able to use Fabrik elements in the HTML that retrieve the data from the corresponding record and display the fields using the Fabrik content plugin. It would speed things up, reduce errors, allow me to make changes to the template that is then reflected across all the records displayed by the component etc.

I have created a list and linked it to the component's main table. I can display this list or its elements in the component using the Fabrik content plug-in. This is great! However what I am not sure is how to get Fabrik to retrieve the relevant rowid from the component's active record. In principle I need to say to Fabrik "this is the record the component is displaying, now find the corresponding record in the linked Fabrik table and display the respective elements added to the content." At the moment I have to specify the rowid for each element, which defeats my objective.

I hope I have made this clear (!) and would appreciate any advice. If I can do this Fabrik will do the job brilliantly!

TIA
 
Is the record the component is displaying identified in the url or in an element on the current page? If in the URL, you can filter via the content plugin with something like:

Code:
{fabrik view=list id=1 tablename___elementname=[param1]}

You did say list which implies display versus form which implies edit, so the above is for display. If there is a page element containing the data to filter on and it is not in a URL parameter, you can use javascript to get the value from the page element then use that value to filter the list on load via an ajax redirect or similar. See http://fabrikar.com/forums/index.php?wiki/filtering-lists-tables/ for info on filtering via the url.
 
The component does display the current component record in the URL. I did see this URL filter in the wiki, but it appeared to work for a list not an element, which is what confused me.

The goal is to display information rather than allow editing. I have spent some time on the presentation of the data (i.e. the HTML and CSS). If I currently have (for example):

HTML:
<h1 class="myh1class">My header</h1><p class="mydescription">Description here</p>

in the content of the component, what I want to do is store 'My header' and 'Description here' in Fabrik and then substitute this in the HTML:

HTML:
<h1 class="myh1class">{fabrik view=element list=1 rowid=2 element=groupname___myh1}</h1><p class="mydescription">{fabrik view=element list=1 rowid=2 element=groupname___mydescription}</p>

What I need to be able to do is query the current component record so I can substitute the correct value for the rowid of the matching Fabrik table. However the URLs are SEF friendly so rather that displaying the current component record's id value a SEF string is displayed.

There are probably several ways to do this, probably involving Javascript and/or PHP/MySQL. I will have a look at the information on filtering via the URL.

Thanks for your help :) it is appreciated!
 
Your very welcome... also just FYI - even with SEF URL's the query string parameters in the URL's are still there and accessible, just not visible unless your turn off SEF. So, you should still be able to substitute rowid=2 with something like rowid=[myurlparam] and get the value from the url that way if it is there.

Regards,
Dale
 
Thanks Dale that is really helpful. I did not realise that the query string parameters are still there with SEF URLs, but tht does make sense.

I'll turn off the SEF URL to check the query string. Once I can work out how to parse the URL correctly it should work.

Regards,

Andrew
 
Just to expand on that, for anyone running across this thread who is curious about this.

Every component (well, almost) in J! has a "router". If SEF is enabled, one of the things the router does is interpret SEF'ed strings. When J! gets an incoming request, one of the very first things it does is hands the URL to the destination component's router. Which then parses it, and hands J! back an un-SEF'ed version of the query string. So, for instance, Fabrik would look at '/form/3/1', and hand back J! "&view=form&formid=3&rowid=1" (well, a data structure which represents that, anyway). J! then sets up the various global arrays, like $_REQUEST, and the internal J! application input arrays accordingly.

So as far as any code running after the router is invoked is concerned, there is no difference between a SEF'ed and un-SEF'ed query string.

The same thing then happens in reverse, if the component wants to (say) redirect to a J! URL, or build links to other parts of itself (like, say, form/detail links in Fabrik lists). The component hands J! the normal, un-SEF'ed URL it wants to use, J! looks at the option=com_whatever part, calls the appropriate component's router, which builds the SEF'ed version, which J! then hands back to the code that asked for it.

For the insatiably curious, our router code is in ./components/com_fabrik/router.php

-- hugh
 
Thanks Hugh, I had no idea :)

The component I wish to extend allocates an id number to a record (a 'course' in the component). So if I wanted to create a course on 'Using Fabrik' it would allocate create a record with 'id=100' (or whatever...). Without SEF URLs enabled the query string would include id=100 to specify the course. With SEF on 'using-fabrik' would be in the query string.

From what you and Dale have said, I could therefore parse the URL for 'id=100' even though SEF URLs are on then set the filter accordingly. Is that correct? How is this best implemented? I assume that some Javascript would need to be invoked on loading the page that would identify the id value in the URL and then have the fabrik content plugin in the content on the page filter for the correct record.

Since I know what the id value of the component record is, I was initially hoping that I could simply set this in the content HTML as a filter and the Fabrik elements specified in the content would display that data of that record. That way I would not need to parse the URL. However the filter has to be set for each element, which defeats the purpose of the exercise. Is that correct or have I missed something?

Andrew
 
Thanks I shall have a good look at the details view. I did have a look at that wiki page but missed the significance (I thought that form and list were the only options :oops:). This looks like the answer :cool:
 
If the (non SEF) URL contains &id=100 you can do as genyded is suggesting:
{fabrik view=element list=1 rowid=[id] element=groupname___myh1}
(I hope a parameter called id won't break anything)

Instead of loading multiple elements why don't you load a details view
{fabrik view=details id=X rowid=[id] layout=your-custom-template}
X= your form ID

http://www.fabrikar.com/forums/index.php?wiki/form-and-details-templates/
I have now been through the video (many) times and not only have learned loads but also have created a basic custom template that works :)

There are some small changes when using Fabrik 3.1, but these are fairly easy to determine and is a good learning exercise anyway.

Thanks to everyone who has helped. What a great tool this is! I know I am only at the very beginning but how exciting.
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top