Javascript messes with orderBy in my CRUD in Laravel Backpack - laravel-backpack

I followed the process in this question and everything works, but I wanted to see the order in my displayed page.
I updated My controller with this:
$this->crud->orderBy('lft');
But it doesn't seem to work. I then desactivated the JavaScript, and the order was correct. It seems the JS reorders the contents when loading the page (I assume it's by the contents IDs).
How can I disable this behaviour ? (Only the one made while loading the page, I want my users to be able to reorder by columns).

This was a bug - DataTables ignored the order set by Eloquent and just did his thing. This has been fixed in the latest version of Backpack\CRUD, so a composer update should fix it.

Related

Datatable Footer Callback

Is there any feature for this footer callback?
https://datatables.net/examples/advanced_init/footer_callback.html
I would like to sum up a column for each page or filter the data.
As I read the src/resources/views/crud/inc/datatables_logic.blade.php seem like does not have the footer keyword.
Not sure this version support for this?
You can publish the blade file using php artisan backpack:publish crud/inc/datatables_logic. Then you'll find it in your resources/views/vendor/backpack/crud/inc/ and be able to change it to fit your needs - like adding your own footer callback logic.
This is perfectly fine to do when you need a feature that Backpack doesn't support out-of-the-box (it can't possibly support everything) - but make sure you don't overdo it and publish a lot of blade files. When you're publishing a blade file:
you're basically forfeiting the minor updates for that file;
when a new major Backpack version comes around, if it has breaking changes in that particular file, the fact that you have it published and customised will make it a little more difficult to upgrade - you'll need to look at the diff between the files and manually make the same breaking changes;

TYPO3: tx_news: separate pagination between plugins

I'm using TYPO3 7.6 with the latest tx_news release from TER.
I want to show two news plugins at one page: one is configured to show all news from storage folder "A"; the other one is configured to show only the latest record from storage folder "B".
Now, once the first plugin paginates, the second one renders empty content since it tries to paginate as well (which doesn't make sense since it should display only the latest record).
So, my question is: How can I separate the pagination between both plugins?
In TYPO3 7.6 there is no solution to your issue, sorry. Workarounds include adding manual pagination for the second plugin or overriding the second widget with one that forces a different ID.
In TYPO3 8.6+ you can override the ID of each widget which causes the URL scope to change so you can isolate parameters for each widget. More information can be found on https://docs.typo3.org/typo3cms/extensions/core/8.7/Changelog/8.6/Feature-47006-ExtendTheWidgetIdentifierWithCustomString.html
I tweaked the fluid template to totally avoid the pagination in this case (based on "settings.templateLayout"
In the meantime (I don't know whether it was in place three years ago) there is an option Hide the pagination in the news plugin. You will find it in the tab Additional.
So if you place more than one list view on one page, you can disable pagination for all lists, which should not get paginated.

SugarCRM fetching data from outside REST service to subpanel

I'm trying to create subpanel in Account detail view where list of elements is fetched from external REST service.
I know how to define subpanel, but have no idea how to fill it with data from external network source. Was trying to use get_subpanel_data but there I can only change SQL.
Any ideas how can I do this?
When I've done this in the the past, at least with Sugar 6, I opted distinctly not to try to create a true subpanel. The data being loaded is coming from an outside source and is loaded dynamically with the page, so why present it as if it's static data coming from Sugar? Instead, I created a custom Smarty template to use as the footer on the detail page. For such an example, you can check how it works on the Calls Edit View. I think it's the footerTpl parameter in the detailviewdefs.php or editviewdefs.php. I loaded the smarty template by creating a custom detail view for my module, so custom/modules/MyModule/views/view.detail.php - extend the base Detail View class and override the display to feed Smarty new params, then your Smarty template only needs to iterate through and present the data that your view defined.
To be super-hip and abide by MVC, you could even put your custom code into your bean (if it's a custom module) or into a custom controller method, then reference that from the view.detail.php, and still feed it from there to the Smarty template.
Alternatively, you could just load JavaScript into the Smarty template and use the JavaScript to call the third-party service, parse and present it, etc.
I realize this question is a little bit old now however it comes up fairly often so why not provide an answer with a couple possible solutions. I won't get into code but more just into the design theory of how it can work. If someone needs more specific code help then that is another question.
A couple ideas...
As you mentioned you can define a custom Function which will load in Data to the SubPanel from your own SQL Query. That is one method that I just recently got to finally put to use after knowing about it for a good year and a half.
When you go this route, you are restrained to using the Columns in the SubPanel. I assume it is using the actual Metadata files to determine which Field Columns a SubPanel can use so you pretty much need your custom data in a Database table to have the same column names as the fields defined in the SubPanel Metadata.
Obviously this works great in the right situation, however not always and that leads us into the 2nd method I know of.
The other way is pretty much what #Mattew-Poer mentioned in his answer. It means abandoning the SubPanel altogether and instead generating your own HTML. This is by far my favorite and prefered way of doing it and I have been some really custom modules due to this being possible in a custom module! I will show an example below.
(Click HERE to View full size image)
In the screenshot, you can see in this example that I have something looking Similar to a SubPanel however it is not and is much for flexible and easy to customize.
Example, to the far left column in my fake subpanel is image checkboxes. When clicked on, an AJAX request is made to change the Task row Status.
After that, the checkbox image is updated to indicate the new Status state, the Modified DateTime is updated, the Status column has color background SPANS and is also updated with the correct text and background color when the left side checkbox is clicked.
Doing any of this with the standard SubPanels is a complete nightmare and would be difficult to do some of the stuff that you are open to do when you build your own version of a SubPanel.
With that said, I have built an identical clone of the above screenshot using SugarCRM default SubPanels! It was a nightmare. I could easily update the content and HTML in some of the columns. I even had the AJAX click checkbox image to update and do all the other updates I mentioned above. It wasn't too hard and worked fairly good but it had some issues.
When you do inline edit, inline create record, or subpanel paging to load different set of record. You would then lose all the custom HTML formatting that was applied. The reason is, in the SubPanel you are limited to using the After UI load logic hook. So since the "Page" is loaded already, when an AJAX request is made to add/edit the subpanel content or load a new set of items with the paging links. It only loads the SubPanel content on those events and the whole Page content does not reload. Because the logic hook only fires off 1 time after the page loads, this newly loaded subpanel data doe not receive any of your custom HTML formatting.
In my case, this means that nice looking colored background Status spans are lost, the image checkboxes are lost, and some other functionality is lost.
Now to get super technical, I could have gone another 3rd route and instead made new Custom Field Types for each SubPanel filed that I needed to apply custom HTML to. This process is super hard in my experience and in some cases it really isn't the BEST solution.
Because of the reason explained, this is why my new modules use the Custom HTML route to generate my own version of a custom subpanel or whatever Data is needed in my Module pages! So far it is working better than I imagined and has opened doors for me to build custom SugarCRM modules that I previously didn't even realize would be possible to build due to some of the issues I mentioned above. Now I bypass them altogether and open the door to do pretty much anything!
I've got some really cool stuff for SugarCRM in the works right now. If anyone has any questions feel free to ask in a new question or for me personally in a comment here.

How to manually order Typo3 news articles in the list view?

I am using the news plugin to simulate the classic page content elements but with previews. Now I would like to be able to manually set the order of the articles just as I would in the page module for the standard elements. But there seems to be no such option in the list module. How would I achieve such functionality?
There is an extension that adds a sorting field to tt_news so you can order the news entries in the list view. It has not been maintained for quite some time, but since it works on TCA and FlexForm level, it should still work with never versions. Check it out:
http://typo3.org/extensions/repository/view/mpossnewssorting

No rights on page-module level

I encounter a strange error. On page-module level i´m not allowed to create new page elements. If i do the same via the list-module page-elements are created and i can edit them (even in the page-module).
Also, if i created a flexible content element - e.g. columns - (via the list module) i CAN create new elements in the flexible content element, even in page module.
New elements are always on TOP of the page, meaning the first entry, and i can´t drag and drop them. Well, i can, but changes do not come in effect. To sort the elements I have to edit the page properties, and sort content.
The user has every right(!) given by the user settings, and it is TYPO3 4.7.4
Does anyone know where i have to look for a solution? Thanks in advance!
Edit 1
This error appears in the log:
Attempt to insert record on page '[root-level]' (0) where this table, tt_content, is not allowed (msg#1.1.11)
Again: Creating Elements IS working via the List-Module.
This error is causen because the field t3ver_swapmode in the page table was removed since TYPO3 4.7 (Maybe in combination with TemplaVoila).
I dont know whats exactly going on here (didnt had the time to find that out), but the solution is of cource simple. I uploaded my fix to the TYPO repository under the key swapmodefix http://typo3.org/extensions/repository/view/swapmodefix
The extension appears in a couple of hours, good luck!
You need to select a page inside the pagetree first. You may not create content elements on the root page.
It might be that the selection is lost, but still visibel. Just click the page again.