In older projects (< TYPO3 7.6) I was using the following code to load a page with a pagenum:
ajax = PAGE
ajax {
typeNum = 2008
10 < styles.content.get
10.stdWrap.innerWrap >
config {
disableAllHeaderCode = 1
additionalHeaders = Content-type:application/json
disablePrefixComment = 1
xhtml_cleaning = 0
admPanel = 0
debug = 0
no_cache = 1
}
}
Now we're working with TYPO3 8.7 and Fluidcontent and when using this code, a blank page is being outputted, no content. I had a look into the Object-Browser and it seems that styles.content.get should still work.
I'm afraid it doesn't work anymore because of Fluidcontent and the different structure for backend layouts. Unfortunately, I could not find anything helpful on Google. Does anybody know how to use this (load page via pagenum) with Fluidcontent in TYPO3 8.7?
styles.content.get is defined very late with fluidcontent. so your copy might copy an up to then undefined/ empty definition.
either use the reference operator =<,
define it by your own:
.
styles.content.get = CONTENT
styles.content.get {
table = tt_content
select {
orderBy = sorting
where = colPos=0
}
}
or use this immediately:
.
ajax {
10 = CONTENT
10 {
table = tt_content
select {
orderBy = sorting
where = colPos=0
}
}
}
Related
I've followed this tutorial to create a custom dynamic backend configuration with serialized data, and everything is working as expected. yay
But now I want to take another step and only show some inputs when a specific value is selected in a select box. I know that I can use when doing this with system.xml, but how can I accomplish the same thing via code with dynamics serialized tables?
I ended up doing some kind of Javascript workaround to enable/disable a certain input.
function togleSelect(element)
{
var val = element.value;
var name = element.name;
if (val == 0) // select value to be triggered
{
name = name.substr(0, name.lastIndexOf("[")) + "[name_of_my_input]";
var target = document.getElementsByName(name);
target[0].disabled = false;
}
else
{
name = name.substr(0, name.lastIndexOf("[")) + "[name_of_my_input]";
var target = document.getElementsByName(name);
target[0].disabled = true;
}
}
It's not the best solution but it's working.
I have an extension which adds a custom content element called "Products".
I'm trying to make an ajax pagination. When I try to get the products list with styles.content.get, the products are rendered correctly, but when I'm using the extbase way, I get no products.
The custom page type:
ajaxProductList = PAGE
ajaxProductList {
typeNum = 6
config {
disableAllHeaderCode = 1
additionalHeaders = Content-type:text/html
}
# WORKING
10 < styles.content.get
10.where = CType='products_main'
# NOT WORKING
10 = USER
10 {
userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
extensionName = Products
pluginName = Main
vendorName = Vendor
}
}
Any idea why?
EDIT:
Adding the storagePid manually under vendorName fixes the issue, but is there any way this could be considered automatically?
persistence.storagePid = 116
Via Typoscript I want to handle a reaction form with ajax. I have configured the page with the Typoscript code shown below.
But I keep getting the Typo3 error that the page is not configured?
1294587217: The page is not configured! [type=15191][]. This means that there is no TypoScript object of type PAGE with typeNum=15191 configured.
ajaxComments = PAGE
ajaxComments {
typeNum = 15191
config.tx_realurl_enable = 0
config.disableAllHeaderCode = 1
config.disablePrefixComment = 1
config.metaCharset = UTF-8
config.no_cache = 1
config.additionalHeaders = Content-type:application/json
10 = USER
10 {
userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
pluginName = backend
extensionName = extName
controller = Main
vendorName = venName
action = sendComment
switchableControllerActions {
Main{
1 = sendComment
}
}
settings =< plugin.tx_extName.settings
persistence =< plugin.tx_extName.persistence
view =< plugin.tx_extName.view
}
}
i am working on simple hotel reservation system that users enter their info, like hotel or room. in every page i have footer bar that show feedback of system when user do something. for example when user add hotel , after doing this,when he redirect to any pages, in footer bar, immediately, display , "hotel added successfully".
|----------------------------------------|
| |
| GridView |
| |
| |
|----------------------------------------|
|hotel added successfully ! |
|----------------------------------------|
the solution that i am using is :
when users log something , i log it
and i define div[id=notification] in shared/_layout, and using a worker to call a function that check log database and get new ones.
// i use worker to repeatedly invoke function to check db
var worker = new Worker('../Scripts/worker.js');
worker.addEventListener('message', function (e)
{
if (e.data != "")
{
var result = e.data;
var results = result.split("##");
if ($("#notificationID").val() != results[1])
{
$("#notificationID").val(results[1]);
}
}
}, false);
and the function to check db is
public string GetNewTrans()
{
string userName = Membership.GetUser().UserName;
using (var context = new jobEntities())
{
var query = from p in context.Logs where p.UserName==userName && p.IsNew == null orderby p.ID_Log descending select p;
if (query.Count() > 0)
{
var log = query.FirstOrDefault();
DateTime c= DateTime.Parse(log.RefreshDate.ToString());
var sec = DateTime.Now.Subtract(c).Seconds;
if( sec> 2)
{
log.IsNew = "false";
context.SaveChanges();
}
var result = log.Section + " : " + log.Action +"##"+log.Success.ToString()+"##"+log.ID_Log.ToString();
return result;
}
return null;
}
}
now i think that when number of users increase , the load of check db increase and cause to make pages slower.
so do you have any better solution ?
and my framework in asp mvc 3.5 and use EF 4.1
The better solution to get some data from db its using JsonResult action controller to get json data and than modified on the client.
As for info messages you can add TempData["message"] object in your controller and in redirecting View
I decided to implement caching to improve the performance of the product pages.
Each page contains a large amount of the product's images.
I created the following code in a Razor view.
#{
var productID = UrlData[0].AsInt();
var cacheItemKey = "products";
var cacheHit = true;
var data = WebCache.Get(cacheItemKey);
var db = Database.Open("adldb");
if (data == null) {
cacheHit = false;
}
if (cacheHit == false) {
data = db.Query("SELECT * FROM Products WHERE ProductID = #0", productID).ToList();
WebCache.Set(cacheItemKey, data, 1, false);
}
}
I'm using the data with the following code:
#foreach (dynamic p in data)
{
<a href="~/Products/View/#p.ProductID"
<img src="~/Thumbnail/#p.ProductID"></a>
}
The caching code works well, but when passing the new query string parameter (changing the version of the page) the result in browser is the same for the declared cashing time.
How to make caching every version of the page?
Thanks
Oleg
A very simple approach might be to convert your key (productID) to a string and append it to the name of your cacheItemKey.
So you might consider changing the line:
var cacheItemKey = "products";
to read:
var cacheItemKey = "products" + productID.ToString();
This should produce the behavior you are looking for -- basically mimicking a VaryByParam setup.
ps. Please keep in mind I have not added any sort of defensive code, which you should do.
Hope that helps.