Select urls from Typo3 Database via Typoscript query - database

First my goal: I want to create a list with links to internal pages. This list has to be ordered by creation date (crdate in the DB)
To achieve this, I wrote the following code:
99 = CONTENT
99.table = pages
99.select {
pidInList = root,-1
selectFields = url
orderBy = crdate
}
Sadly, this returns nothing.
For debugging I played with the different properties.
With
99 = CONTENT
99.table = tt_content
99.select {
pidInList = 1
orderBy = crdate
}
I cloned my rootpage. I got all records from it.
So I know that all page records should be stored in the Pages table with the url.
What am I doing wrong here?
Additional information: Typo3 8.7, no the default backend elements are not working for me, yes I have to do it in typoscript
Thanks in advance for any suggestions.

The field url in the pages record does not hold the url from that page in general.
It is used only for pages of type external URL, so the internal link to this page can be forwarded to that url.
If you want a link list of all your pages you need to create a link to these pages:
99 = CONTENT
99 {
table = pages
select {
// your selection here
}
renderObj = TEXT
renderObj {
typolink {
parameter.field = uid
}
}
}
This will give you a list (if wrapping the renderObj with <li>|</li>) of complete links with page title as link text.
If you want only urls you can add:
typolink {
returnLast = url
}
Without wrapping it will be a long string without separation.
EDIT:
99 = CONTENT
99 {
table = pages
select {
pidInList = 69
orderBy = crdate desc
}
wrap = <ul>|</ul>
renderObj = TEXT
renderObj {
wrap = <li>|</li>
typolink {
parameter.field = uid
}
if.isFalse.cObject = CONTENT
if.isFalse.cObject {
table = pages
select {
// this 'uid' is from context of current pages record we have selected above
pidInList.field = uid
// this 'uid' is the field from the records we are selecting here
selectFields = uid
}
renderObj = TEXT
// this 'uid' is the selected field above
// a field in the pages record of the subquery to decide if there are child pages
renderObj.field = uid
# renderObj.wrap = |,
}
}
}

Related

Relay Modern: delete record in optimisticUpdater

In my app I have a mutation where I want to use the optimisticUpdater to update the view before the server response. For that I need to remove some records from a list into the relay store, like that:
optimisticUpdater: storeProxy => {
storeProxy.delete(recordDataID)
}
The problem is that relay don't remove the record, but it transforms the record in null.
This can be annoying because I have to filter the list every time I use it in my app.
Some one know how can I remove the record ?
thx
You have to remove your records from the list
optimisticUpdater: (store) => {
const listOfRecords = store.getRoot().getLinkedRecords('list')
const newList = listOfRecords.filter(record => record.getDataID() !== recordDataID)
store.getRoot().setLinkedRecords(newList, 'list')
}
In this example I assume your list is placed at the root of your graph
If you decorate your query with #connection, then you can use the ConnectionHandler to easily remove records:
const query = graphql`query WidgetListQuery {
widgets(first: 10) #connection(key: "WidgetList_widgets") {
...
}
}`
optimisticUpdater(store) {
const widgets = ConnectionHandler.getConnection(store.getRoot(), 'WidgetList_widgets');
ConnectionHandler.deleteNode(widgets, deleted_widget.id)
}

How to get the token value from meta tag in a outlet page - Drupal 7?

I need to display the meta tag values from the meta tag tokens.
My Code:
function MyModule_html_head_alter(&$head_elements) {
$head_elements['metatag_description']['#value'] = $outlet_description;
}
Actual Output:
[node:node_sections] - [node:field_lead_text] Testing
Expecting Output:
Food - Testing lead text Testing
You have to use token_replace function
$menu = menu_get_item();
if($menu['path'] == 'node/%') { // check if you are on node page
$node = $menu['page arguments'][0];
$head_elements['metatag_description']['#value'] = token_replace($outlet_description, array('node' => $node));
}

I want to add dropdown that comes from custom table in typo3 solr facets

I have indexed page correctly and solr is working, but I want to insert facets.
I have write below typoscript for adding contain of table tx_srcdataprovider_domain_model_tag, it added in index queue but not indexed properly.
How do I show all tag fields in dropdown in facets?
Please give me some example to add facets in typo3 solr.
Thanks in advance
tx_srcdataprovider_domain_model_tag = 1
tx_srcdataprovider_domain_model_tag {
table = tx_srcdataprovider_domain_model_tag
fields {
tag = tag
// the special SOLR_CONTENT content object cleans HTML and RTE fields
content = SOLR_CONTENT
content {
field = description
}
// the special SOLR_RELATION content object resolves relations
category_stringM = SOLR_RELATION
category_stringM {
localField = category
multiValue = 1
}
// build the URL through typolink, make sure to use returnLast = url
url = TEXT
url {
typolink.parameter = 1
typolink.additionalParams = &tx_srcdataprovider_domain_model_tag[item]={field:uid}
typolink.additionalParams.insertData = 1
typolink.returnLast = url
typolink.useCacheHash = 1
}
// the special SOLR_MULTIVALUE content object allows to index multivalue fields
keywords = SOLR_MULTIVALUE
keywords {
field = keywords
}
tag_stringS = tag
}

How to set default id as 0 for new tags

How to set a default id to 0 for the tags which is not from the list ?
[DEMO LINK][1]
LINK
In the above e.g if we select from existing, then it comes with id (1 or 2 or 3), but if add new Tag and press enter then the id becomes as text, i want id to set as o for new tag OR not from the list.
How to do that?
CreateSearchChoice should be what you are looking for
here is a similar SO i asked a while ago select2 createSearchChoice id from post
createSearchChoice: function (term, data) {
if ($(data).filter(function () {
return this.text.localeCompare(term) === 0;
}).length === 0) {
// if not found in current list
// return {id:term, text:term}
return {
id: term,
text: $.trim(term) + ' (new tag)'
};
},
Note i am setting the id to new text term, you could set it to a concatenated value like -1/term, then parse it out later, but term must be included in the ID for this solution
then on the change event, i determine whether the id is numeric (exists already). if its not numeric (added in the createsearchchoice) I go through my process of posting to the database of tags
.on("change", function(e) {
if (e.added) { //is it added from select2
if (isNumeric(e.added.id)){ //did it already exist or createsearchchoice
add(e.added.id); //it already existed, just add it to the tag list
} else { //id was created on the fly, post to the database and return a tag id
$.post('handlers/tags.ashx', {
operation:"select2createtag",
//because its not numeric, we know id = new tag text
text: $.trim(e.added.id)} ,
function(data){
//set the added id to the id you just returned from sql
e.added.id = data.id;
//...do something else, like then add the new tag to the item
});
};
};
if you dont want to post to ajax, have your server-side evaluate your input items, and any tags that are non-numeric for id , follow the same idea above
I updated your Plunker here

comments module in dotnetnuke

Is there any comments module in Dotnetnuke that can work with the journal module? I mean, if a user comments on a page, the journal module on his profile displays that this user has commented on this page? Or, could there be an item having a link to that page? Just like we have in facebook? I hope you understand my question.
There is no such module. You would have to write your own
This is some sample code from the upcoming Announcements module:
public static void AddAnnouncementToJournal(AnnouncementInfo announcement, int tabId)
{
JournalItem item2 = new JournalItem
{
PortalId = announcement.PortalID,
ProfileId = announcement.LastModifiedByUserID,
UserId = announcement.LastModifiedByUserID,
ContentItemId = announcement.ContentItemID,
Title = announcement.Title
};
ItemData data = new ItemData
{
Url = announcement.Permalink()
};
item2.ItemData = data;
item2.Summary = HtmlUtils.Shorten(HtmlUtils.Clean(System.Web.HttpUtility.HtmlDecode(announcement.Description), false), 250, "...");
item2.Body = null;
item2.JournalTypeId = 33;
item2.SecuritySet = "E,";
JournalItem journalItem = item2;
JournalController.Instance.SaveJournalItem(journalItem, tabId);
}
Important to note: you need to define your own JournalType (in the sample above, this is not fully implemented yet, and using a hard coded value of 33). Basically, what you need is a new record in the JournalTypes table, defining your own journalType

Resources