Not getting ajax response in TYPO3 - ajax

I am using this in my setup.txt to generate ajax calls
myAjaxPage = PAGE
myAjaxPage {
config {
disableAllHeaderCode = 1
debug = 0
no_cache = 1
additionalHeaders {
10 {
header = Content-Type: application/json
replace = 1
}
}
}
typeNum = 427590
10 < tt_content.list.20.documentcenter_list
}
but I am not able to get any response from my controller whereas the Network status gives me 200 as seen in this header and response
What am I doing wrong, or if anyone can guide me would be helpful.

Every time you are using a page which contains a typeNum parameter you have to add it to your URL.
http://exmample.com/index.php?id=48&type=427590
This is the format how your URL should look like.

you need a setup like this:
tx_cardealer_ajax = PAGE
tx_cardealer_ajax {
features {
skipDefaultArguments = 1
}
typeNum = 4711
config {
disableAllHeaderCode = 1
xhtml_cleaning = 0
admPanel = 0
additionalHeaders = Content-type: text/plain
no_cache = 1
}
10 = USER
10 {
userFunc = TYPO3\CMS\Extbase\Core\Bootstrap->run
extensionName = Cardealer
pluginName = Cardealer
vendorName = EXOTEC
controller = Cardealer
switchableControllerActions {
Cardealer {
1 = ajax
2 = list
3 = filter
4 = show
10 < tt_content.list.20.contentautocomplete_content
}
}
}
}

Related

Rotativa BuildFile not hitting the Action Method

I have two action methods in my Controller class:
DetailsAll: to get some data and display in the view
SaveAsPDF: Called on windows.load of DetailsAll.cshtml which should save DetailsAll view as pdf
My issue is in SaveAsPDF Action method. Here I am trying to use Rotativa ActionAsPdf and subsequently BuildFile methods to generate and save the PDF. However, when executing the line "BuildFile", it is not hitting the breakpoint in my DetailsAll Action method, subsequently causing the PDF to be generated blank.
Could you please help where I am going wrong?
[HttpGet]
public ActionResult DetailsAll()
{
var selectionBuilder = builderFactory.GetGeocodeReportSelectionViewModelBuilder();
var companyList = selectionBuilder.Build();
List<GeocodeReportViewModel> viewModel = new List<GeocodeReportViewModel>();
foreach(SelectListItem record in companyList.Companies)
{
var builder = builderFactory.GetGeocodeReportViewModelBuilder(int.Parse(record.Value));
viewModel.Add(builder.Build());
}
var model = new AllGeocodeReportViewModel
{
GeocodeReports = viewModel
};
return View(model);
}
[HttpGet]
public string SaveAsPDF()
{
var report = new ActionAsPdf("DetailsAll")
{
FileName = "OEM_GeocodeReport_" + System.DateTime.Now.ToString("MMYY") + ".pdf",
PageSize = Size.A4,
PageOrientation = Orientation.Landscape,
PageMargins = { Left = 1, Right = 1 }
};
byte[] pdf = report.BuildFile(ControllerContext);
System.IO.File.WriteAllBytes("C:\\" + report.FileName, pdf);
return "true";
}
Finally found the issue after extensive search. I need to send Authentication cookies along with the BuildFile request for this to work. Added the below code and it generates PDF correctly now:
public void SaveAsPDF()
{
var cookies = Request.Cookies.AllKeys.ToDictionary(k => k, k => Request.Cookies[k].Value);
var report = new ActionAsPdf("DetailsAll")
{
FileName = "OEM_GeocodeReport_" + System.DateTime.Now.ToString("MMyy") + ".pdf",
PageSize = Size.A4,
PageOrientation = Orientation.Portrait,
PageMargins = { Left = 3, Right = 3 },
FormsAuthenticationCookieName = System.Web.Security.FormsAuthentication.FormsCookieName,
Cookies = cookies
};
byte[] pdf = report.BuildFile(ControllerContext);
System.IO.File.WriteAllBytes("C:\\" + report.FileName, pdf);
}

Set up step_adjustment in aws_autoscaling_policy from variable in terraform

I am setting up a module to configure autoscaling in ASGs in terraform. Ideally, I'd like to pass in a list of maps to my module and have it loop through them, adding a step_adjustment for each map in the list to the policy, however this doesn't seem to work.
Current setup:
name = "Example Auto-Scale Up Policy"
policy_type = "StepScaling"
autoscaling_group_name = "${aws_autoscaling_group.example_asg.name}"
adjustment_type = "PercentChangeInCapacity"
estimated_instance_warmup = 300
step_adjustment {
scaling_adjustment = 20
metric_interval_lower_bound = 0
metric_interval_upper_bound = 5
}
step_adjustment {
scaling_adjustment = 25
metric_interval_lower_bound = 5
metric_interval_upper_bound = 15
}
step_adjustment {
scaling_adjustment = 50
metric_interval_lower_bound = 15
}
min_adjustment_magnitude = 4
}
I just want to provide the three step_adjustments as variables into my module.
So the way you can do it is as follows:
variable "step_adjustments" {
type = list(object({ metric_interval_lower_bound = string, metric_interval_upper_bound = string, scaling_adjustment = string }))
default = []
}
# inside your resource
resource "aws_appautoscaling_policy" "scale_up" {
name = "Example Auto-Scale Up Policy"
policy_type = "StepScaling"
autoscaling_group_name = "${aws_autoscaling_group.example_asg.name}"
adjustment_type = "PercentChangeInCapacity"
estimated_instance_warmup = 300
dynamic "step_adjustment" {
for_each = var.step_adjustments
content {
metric_interval_lower_bound = lookup(step_adjustment.value, "metric_interval_lower_bound")
metric_interval_upper_bound = lookup(step_adjustment.value, "metric_interval_upper_bound")
scaling_adjustment = lookup(step_adjustment.value, "scaling_adjustment")
}
}
}
# example input into your module
step_adjustments = [
{
scaling_adjustment = 2
metric_interval_lower_bound = 0
metric_interval_upper_bound = 5
},
{
scaling_adjustment = 1
metric_interval_lower_bound = 5
metric_interval_upper_bound = "" # indicates infinity
}]

TYPO3 first available image of content elements

I want to show only the first available image of different content elements in a column.
The following code shows me all available images, but I need only the first one!
Can somebody help me?
lib.contentImage = CONTENT
lib.contentImage {
wrap = |
table = tt_content
select {
languageField = sys_language_uid
where = colPos = 0
orderBy = sorting
pidInList = 32
}
renderObj = COA
renderObj{
wrap = <div class="item">|</div>
10 = FILES
10 {
references {
table = tt_content
uid.data = uid
fieldName = assets
}
renderObj = IMAGE
renderObj {
wrap = <div class="item-image">|</div>
file.import.data = file:current:originalUid
file.width = 1920c
file.height = 600c
}
}
}
}
I used this to get the url of the first image on a page for open graph tags.
page.meta.og:image.cObject = CONTENT
page.meta.og:image.cObject {
table = tt_content
select {
where = (colPos = 0 AND image != 0 )
selectFields = uid
orderBy = sorting
max = 1
}
renderObj = COA
renderObj {
1 = TEXT
1 {
cObject = FILES
cObject {
references {
table = tt_content
uid.field = uid
fieldName = image
}
maxItems = 1
renderObj = TEXT
renderObj {
typolink.parameter.data = file:current:publicUrl
typolink.forceAbsoluteUrl = 1
typolink.returnLast = url
}
}
}
}
}
page.meta.og:image.attribute = property
You would try somethings with LOAD_REGISTER
e.g.: (not tested)
lib.contentImage = COA
lib.contentImage {
5 = LOAD_REGISTER
5.imageRendered = 0
10 = CONTENT
10 {
wrap = |
table = tt_content
select {
languageField = sys_language_uid
where = colPos = 0
orderBy = sorting
pidInList = 32
}
renderObj = COA
renderObj{
wrap = <div class="item">|</div>
10 = FILES
10 {
references {
table = tt_content
uid.data = uid
fieldName = assets
}
max = 1
renderObj = COA
renderObj {
stdWrap.if.isFalse.data = register:imageRendered
5 = LOAD_REGISTER
5.imageRendered = 1
10 = IMAGE
10 {
wrap = <div class="item-image">|</div>
file.import.data = file:current:originalUid
file.width = 1920c
file.height = 600c
}
}
}
}
}
99 = RESTORE_REGISTER
}
Do you need the first one of each Contentelement or the first Image of all Contentelements?
If you only want one image for each element you can set maxItems in FILES Object https://docs.typo3.org/typo3cms/TyposcriptReference/ContentObjects/Files/Index.html#usage-with-references

tt_products imageLinkWrap typolink title for each image

Iam using tt_products and trying to get a "title" param for each link to an Image, which is not provided from this extension. I have some free data-table fields left which id like to use to store the titles für each link.
This is how the Example has to look like in the Frontend after rendering each link and image.
This is the solution that i worked out till now, it loads the content from the fields but it dont split the conten of the field right and apend them to the right images
temp.imageLinkWrap = 1
temp.imageLinkWrap {
stdWrap = stdWrap
enable = 1
typolink {
parameter.cObject = IMG_RESOURCE
parameter.cObject.file.import.data = TSFE:lastImageInfo|origFile
parameter.cObject.file.maxW = {$plugin.perfectlightbox.lightBoxMaxW}
parameter.cObject.file.maxH = {$plugin.perfectlightbox.lightBoxMaxH}
parameter.override.listNum.stdWrap.data = register : IMAGE_NUM_CURRENT
title >
title.override.cObject = COA
title.override.cObject {
10 = TEXT
10{
data {
data = GP:tt_products|product
intval = 0
wrap = DB:tt_products: | :image
}
split{
token = ,
cObjNum = 1
1.current = 1
# for each image, add the imagecaption
1.wrap = |
1.append = TEXT
1.append {
data {
data = GP:tt_products|product
intval = 1
wrap = DB:tt_products: | :quality
}
# split saves the index in REGISTER:SPLIT_COUNT
listNum.stdWrap.data = REGISTER:SPLIT_COUNT
listNum.splitChar = 10
}
}
}
}
title.override.if.isTrue = 1
title.insertData = 1
parameter.cObject = IMG_RESOURCE
parameter.cObject.file.import.data = TSFE:lastImageInfo|origFile
ATagParams >
ATagParams.cObject = COA
ATagParams.cObject {
10 = TEXT
10.value = rel="lightbox[lb{field:uid}]"
}
ATagParams.insertData = 1
}
}
plugin.tt_products {
templateFile = fileadmin/template/html/partial/ext/shop-tmpl.html
pid_list = 23
wrapInBaseClass = 0
requiredInfoFields = agb, name, address, zip, city, email
limitImageSingle = 6
separateImage = 1
listImage < .image
listImage.file.maxW = 300
listImage.file.maxH =
listImage.imageLinkWrap >
image.wrap = <div class="img_single"> | </div>
usePageContentImage = 0
imageLinkWrap = 1
image {
altText = TEXT
altText.data = field:title
imageLinkWrap >
imageLinkWrap < temp.imageLinkWrap
}
}

Typo3 max image size for content elements

I try to set the max image size for a specific content element. How can I do this for the element "content"? I tried to combine several options, but nothing works.
Is the content.maxImageWidthInText.maxH the right way?
Here is my code:
page = PAGE
page {
typeNum = 0
10 = FLUIDTEMPLATE
10 {
file.stdWrap.cObject = CASE
file.stdWrap.cObject {
key.data = levelfield:-1, backend_layout_next_level, slide
key.override.field = backend_layout
default = TEXT
default.value = fileadmin/templates/index.html
1 = TEXT
1.value = fileadmin/templates/index.html
}
variables {
# Content
content < styles.content.get
content.select.where = colPos=0
content.maxImageWidthInText.maxW = 135
.....
}
}
}
There are the registers maxImageWidth and maxImageWidthInText to do that:
content = COA
content {
10 = LOAD_REGISTER
10 {
maxImageWidth = 135
maxImageWidthInText = 100
}
20 < styles.content.get
30 = RESTORE_REGISTER
}
Couldn't find any official documentation though - you can find this stuff using the TypoScript object browser.

Resources