Display plugin

Fred04

Member
hello,

I tried the 'display' plugin on one of my element but it does not show anything...

I also tried to force the system to display something using the option 'eval' but still does not work

return '{company___descr}'; does not work
return '{company___descr_raw}'; does not work

however
return '{company___date_time}'; it works
return '{$mi->id}; it works .... but this is not what I want to display!

My initial company___descr is just a simple company description so I don't see what is wrong.

PS: here is what I can see in my html code:
"company___descr":false,"company___descr_raw":"Fred's Company",
 
what element type is the descr element? Its odd that the none raw value is false, can you see any setting that would effect that?
 
@Rob
1. in mySQL the type is text. Actually when I change the plugin from 'field' to 'display', it converts the element from varchar(20) to TEXT
2. I don't really explain the reason for false

@felixcat
no specific editor, I just type the code in Fabrik
 
I've just recreated a new test table with one element using the plug-in 'display'

Then I went straight in mySQL to create a record. Back to my list / form the text does not show up

see below the html code generated for the form. I'm expecting the name 'fred' somewhere.
 

Attachments

  • ScreenHunter_01 May. 30 20.55.gif
    ScreenHunter_01 May. 30 20.55.gif
    5.8 KB · Views: 545
I don't think the display element does anything on it's own... I could be wrong as I don't use it. :)

So you have one display element called test2.name, being a display element you cannot add data unless directly to mysql.

So what happens when you set Eval to yes within that element and put the following as default?


return '{test2___name}';
 
it works with the php code.

I cannot reproduce what I mentionned initialy in my post so I would consider it as ok.

One more question. why do we have to write the php code to make it work? I would have assume that if you use the 'display' plug-in the system would just display the field :D

and I would keep the php option for more complex configuatation like mixing standard text and placeholders.
 
I guess as default we don't know what you want to display. :)

Maybe that option could be implemented as a feature at some point, or maybe it's suppose to and it's just broken... lol
 
by default you have to enter a 'name' so I would expect that by default you just display the value for 'name'

See my exemple, in my case I just want to display 'comp_name'
 

Attachments

  • ScreenHunter_01 Jun. 28 22.34.gif
    ScreenHunter_01 Jun. 28 22.34.gif
    4.3 KB · Views: 462
So it would be 'If Eval is empty then return default', default being the default element \ field.

Or there could be a yes\no return default switch.

Pretty sure it wouldn't be a huge task to change that.
 
by default you have to enter a 'name' so I would expect that by default you just display the value for 'name'

See my exemple, in my case I just want to display 'comp_name'
Doesn't setting the element's Access setting for "Editable" to a higher user access level (like Special) basically do the same thing?

If the element is a "field" type, you can also use the "Read-only" option to show the value without allowing editing - the difference is that with "Read-only" the element is shown as a (dimmed) input box. And (as I keep harping about) the Read-only option is only available for "field" type elements.:(
 
Doesn't setting the element's Access setting for "Editable" to a higher user access level (like Special) basically do the same thing?

Pretty much. There may be scenarios though when a field is being updated outside Fabrik so you don't want Fabrik to touch it at all. In this case a display element is perfect because all it does is display.

If the element is a "field" type, you can also use the "Read-only" option to show the value without allowing editing - the difference is that with "Read-only" the element is shown as a (dimmed) input box. And (as I keep harping about) the Read-only option is only available for "field" type elements


Personally I would use your first suggestion and rely on the access permissions. The problem with the Read-only option is the fact that it's being controlled by javascript so it can be overidden.

Firebug allows you to modify the contents of a readonly field and actually save it as well, so it shouldn't be relied upon.
 
Thanks Felixcat - I didn't know the security problems with javascript. (I knew I hated it for a reason - LOL)

So that is the solution to problems I'm having where joined tables are meant to be read-only and I don't want users to change any of the elements in the joined records - nor do I want Fabrik to update them? Or doesn't it work like that for joined table elements?

(I'm learning.;))
 
Well to tell you the truth, I can't remember if it's HTML of Javascript code that applies the read-only, but either way it can be overridden by something like firebug.

But yes the display element would be your best bet as it simplies displays via PHP which prevents any override to the data and you don't have to worry about the permission or Fabrik overwritting the data.

Simply selecting EVAL within the display element and putting the PHP code of return {tablename___elementname} will do the job.

But I agree with Fred that it would be a nice feature for it to automatically return the value name of the mysql field if it's the same as the element name. I'm can't think of any reason why this would be an issue at the moment.
 
As you have no doubt worked out by now, the 'display' element doesn't use the database at all. It just displays the 'default' you set in the element settings, run through the placeholder replacement code, and optionally eval'ing it as PHP.

-- hugh
 
the 'display' element doesn't use the database at all

I have to disagree because when you create a new element with the display plug-in it creates a new column in the table.
So how difficult would it be to display the content of this field by default?
 
Well, yeah, it creates a TEXT field, which uses no table space if empty (well, mayb e a byte or three). I think the reason we do that, even though the display element doesn't use it, was to make the element saving code simpler, so if you change the element type to something else which does use the database, we don't have to worry about working out if we need to create or modify a column. And, more importantly, if you change from something else to 'display', possibly by mistake, we don't drop the column and lose all your data.

I've kind of lost the plot of what you are trying to achieve here. The whole point of the display element is it doesn't use the database. The value comes from a single location, in the params of the element metadata table in cases where you want the same thing displayed in every row / form.

Can you re-explain what you are trying to achieve, that can't be achieved with (say) a textarea or field element with ACL's applied so it's read only?

I'm not being difficult, just not understanding what the issue is, despite re-reading this thread from the beginning. If course, being on hour 30 of my day probably isn't helping!

-- hugh
 
to summaryze:

I have a list to populate my database.
Then I have a second list based on the same table that is a mix of 'display' and 'editable' element.

Of course I could used the ACL but even if I set a field with 'editable' = Nobody, Fabrik will POST the value of this field in the database (I have another thread on this issue). There is a risk i believe to loose data integrity.

I know how to use the 'display' plug-in with the placeholders and some php but I would consider it easier for 'beginners' if by default we display the related field from the database.

It is not a big deal. I understand your point of view as well.
 
Hi,
I can see that this conversation were a long time ago, but I want to know if any of you can tell me how can I do to display only the information for the logged user but for another table, not the default users table from joomla.
e.g. My ID in the joomla users table is 13, so I can see the fields related to that number from another table.
I appreciate any help (sorry my bad english)
Felipe
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top