I'm trying to create a Typo3 Extension using extbase and stumbled upon a problem.
What I have done so far is this:
I created a plugin editable via flexform for the backend. The plugin allows for dynamically changing some fields, so the flexform is using inline records that can be stored successfully in the database in their own table tx_jwfrontendusermanager_editorfields. The pid for the table entries is the same as for the content object they are attached to, and an additional field in the table holds the content object's id.
The backend works fine so far, I can create/edit/delete inline records for the content objects without any problem.
Unfortunately, I can't seem to figure out how to access the inline records in the ActionController in the frontend, and I can't find any documentation about how to do so. Could anyone point me into the right direction?
What I have tried so far:
First (primitive) approach: Accessing the flexform inline field like any other field from the form. This just returns the number "7". Obviously it's not meant to be used this way.
Second approach: I created a Model/Repository for the EditorFields table, and mapped the Model class to the table using Typoscript. The mapping itself seems to work fine. Unfortunately, I cannot select just the records that are connected to the current content object. A call to Repository->findAll() returns an empty array.
I debugged the SQL query for the findAll command and found out three problems:
The query filters by the tx_jwfrontendusermanager_editorfield.pid field, but using the wrong page id. The pid used is the one I selected in the plugin's 'Record Storage Page' field, not the one of the content object.
The query does not filter for the content object id, but would show all records for all content objects on the page.
The query filters by an additional
`tx_jwfrontendusermanager_editorfield`.`type` = "\Jw301\JwFrontendusermanager\Domain\Model\EditorField"
Which doesn't make any sense, as none of the records has the type field set to something like this. The type is used by the backend to distinguish between different kinds of records. That way, the query will never have any results.
So, how can this be changed in a way that the Repository finds the correct records? Is this even the right approach?
Third approach: As the Repository approach wasn't successful, I tried to get the records myself by creating a custom SQL query. This works in general, but I still have trouble filtering the right records for me.
I can get the current page id easily using
$GLOBALS['TSFE']->page['uid']
But there seems to be no way to get the content object id in the ActionController. I found many Internet sources that said I should use
$cObj = $this->configurationManager->getContentObject();
$cObj->data['uid']
from within the ActionController to access the current content object id, but for me that didn't work. I tried this in every ActionController in my project, yet the uid field was never there. The $cObj I get is of type ContentObjectRenderer, but the data array is always empty.
How can I access the content object uid from within an ActionController?
Thanks for any help or hints that lead me into the right direction.
Related
I am having some trouble accessing x-model data in my laravel app and storing it into my database. Wondering if anyone can help.
So the issue seems to be coming from the fact that I have the category select as a separate blade that I call multiple times.
So ultimately, this code is called three times on my main page. I can then choose three separate categories - but when I try to call those selections and store them in database I run into an error.
Wondering if anyone has any ideas how to access the three separate categories being selected and add them to database. Some links or documentation to check out would be mighty helpful!
Using alpinejs, php, and laravel.
EDIT
In this particular case I am passing the information into the blade through the controller.
EDIT 2:this shows $selection_id
x-model takes the name of a variable inside x-data, not the value.
$selection_id here is a value.
You should do something like:
x-data="{ selection_id: {{$selection_id}} }"
on the component element
then inside x-model:
x-model="selection_id"
Note: Your code is missing, please add the part with the `x-data showing.
I'm trying to figure out how to modify a module in SugarPro, version 6.0.4. The module contains a "key" that is basically a string of characters and this key I would like to append to a base URL and have it be a new field (keys_c) in the module. There are thousands of these keys so it would be nice if this could be generated automatically.
I got it to work as expected with an exception (and misunderstanding). The base_url{key} in the Generate URL option for the module field works but it only displays in the module Detail View. In the module List View it does not show up. I looked through all the listviewdefs.php files I could find and they all seemed to be OK, but perhaps I don't know what to look for.
The result should look like this:
example.com?page=key&key=1a2b3c4d5e6f7g
To recap: this base_url{key} works but only shows up the module's Detail View. In the Edit View the field is missing (eg, not editable) and the list view, also missing. The goal here is to get it to show up in the List View.
Then I looked in the database and the new field shows up as keys_c, for custom. In fact, the database shows a new table called keys_cstm, adjacent to the keys table. The new keys_cstm table has an id_c and keys_c rows. So now I have keys and keys_cstm tables. The default value for the keys_c is:
example.com?page=key&key={key}
But then in Sugar when I go to the Detail View for one of these keys (this works), I see the new field (good) and then in the database a new record is created.
It looks like the value doesn't end up in the database, and is generated on the fly. I guess this is what is meant by "Generate URL". So my question becomes: how to generate all these URLs and store them in the database?
The whole point of this option in Sugar is to create a link on the fly. I've used this function correctly and it works as expected. However, the problem is, I want something else from the system that is not available.
i am trying to create a custom solution for a client using their prior system. The client is using Miva which is a user friendly CMS type system to manage their store. The problem is prior to yesterday everytime i entered a record in the miva site it would show up in PHPmyadmin and I could query it and use the Custom solution. FOr some reason now when I create products in the admin I get no records in the DB.
The product is clearly there
but not stored in the db, any ideas on how and where is stored
Logic dictates that either:
Your query was wrong
You're querying the wrong database
The website does not relate to the database you're querying
You're asleep and none of this is real.
Are you able to do a wildcard search for something specific like a piece of text or file location? If no errors are being thrown when you're adding items then it should be there.
I am currently trying to perform pagination using CakePHP's pagination helper.
I have a series of "Listing" rows that are returned and paginated as expected. When the user clicks on the column headings however, I'd like the sort() method to be forced to prioritise certain listings (i.e. priority listings, those with ['Listing']['priority_flag'] = 1) first. However, when the user clicks on the column header, the browser url is set to
www.mysite.com/listing/index/page:1/sort:description/direction:asc
Hence, it is only sorting by description (as the user clicked on the column header for 'description'), ignoring anything to do with priority_flag.
All help appreciated!
gaioshin
I did this by writing an override paginate() function on the appropriate model. For the parameters, look carefully at the structure of the url you have pasted (you can modify it to suit your own ends, but then you would need to deviate from the pagination helper).
It's not difficult to do, but will require some thought. Look at the core to see how it works.
I have a link in my system as displayed above; 'viewauthorbooks.php?authorid=4' which works fine and generates a page displaying the books only associated with the particular author. However I am implementing another feature where the user can sort the columns (return date, book name etc) and I am using the ORDER BY SQL clause. I have this also working as required for other pages, which do not already have another query in the URI. But for this particular page there is already a paramter returned in the URL, and I am having difficulty in extending it.
When the user clicks on the a table column title I'm getting an error, and the original author ID is being lost!!
This is the URI link I am trying to use:
<th>Return Date</th>
This is so that the data can be sorted in order of Return Date. When I run this; the author ID gets lost for some reason, also I want to know if I am using correct layout to have 2 parameters run in the address? Thanks.
Yes, the layout is correct. Of course it's possible to have even more than 2 parameters in the query string
you have to check resulting query string (just take look into your address bar after click), there must be something like viewauthorbooks.php?authorid=22&orderby=returndate. If number is lost, you have to check it's source - $row['authorid'] variable.
you have to use & and sanitize your output, but apart from that it's correct ;)