Generate json feed from ext:news - typo3

TYPO3 7.6.16 ext:news 5.3.2
We're looking to create a json stream of news stories that have been created in the CMS so that we can consume the feed in other applications.  For each element in the feed we're looking include some simple properties such as the news story name, when it was published and a link to the news story, so that we can direct someone back to the relevant page on the Website.  
We've been able to return a list of news stories by querying the tx_news_domain_model_news table.  From this table we've been able to query all the information that we need from the story, but we're having trouble building a link to the story.
The links that the news plugin is building for each story at the moment takes the form:
/story/tx_news_pi1%5Bnews%5D=18&tx_news_pi1%5Bcontroller%5D=News&tx_news_pi1%5Baction%5D=detail&cHash=a6e542381e508c0501a09383cedc4d70.
So the id field of the news story field is included as a parameter.  We've tried making links by adjusting this parameter for the various Ids of different news stories, but each link allways returns the same news item.  So we are assuming that the hash value for each nwes story has to be calculated for each item to find the correct story.
Our question is.  Is it possible to build a unique URL for each story based on the information in the tx_news_domain_model_news table or is there a better way to create a JSON feed for each news story which includes the link to the original article.

You could define a special page rendering. either a new page or a new pagetype of an existing page.
You use a page object and instead of the usual include of a template the whole content is generated by a CONTENT object. With this you select all news records and define a renderobject where you can use FLUIDTEMPLATE or build up the rendering in typoscript.
In this way you can generate 'normal' URLs, which also might be niced by realurl.
If you want to output other formats than HTML you propably need to escape string-delimiters in your texts and strings.
Fluid templates may be a little bit complex if you have a format where whitespace is important. In typoscript whitespace can be handled with stdWrap.noTrimWrap

Related

Blog-like single element pages with TYPO3 / TemplaVoila

I have a blog-like part of an page using TYPO3 / TemplaVoila. There are articles that should show up summarized on a single page, but have their own pages / URLs each one too.
However, having the editors add a page AND a flexible content element for each entry is complicated.
So is it possible by some typoscript to have a page, showing a single content element from some other page, sporting a proper URL without having to setup an extra page for each element?
What you want is doable without TV and with other records than tt_content.
e.g.: ext:news does it: the content are news records, which are shown with plugins in list- and detail-mode.
Of course you can reinvent the complete logic of such an extension so you can do it with tt_content records, which could be stored in the usual way scattered on multiple pages.
But the logic is clearer if there only is one page (or very few pages which represent some categorization) where special records are stored.
Plugins would be configured to show only selected records (from one category, which are marked top, which are current, ...) and you have one page (one for all and not for each news one) where the records are shown in detail.
Also each has it's own URL, either with URL-parameter (by default) or you configure realurl (or similar) to build a "real url" from news title (and uid).

News Component Requirement

We have a requirement to create a News Component. So there will be news pages which we will author contains Title, Image & description. I will store this under one node say content\myproject\newsnode\news1,news2 like this.
On the homepage, I want to show the latest 3 authored news description. For that, I'm thinking of using a news component.
I thought of creating 2 component and map them. Thinking of using the Query builder to fetch the latest news to show on homepage. One component of news page and one component on a homepage to show latest 3 news with Title, Tile image and a small description.
Is there any other approach to this?
If you are using a dispatcher, querybuilder servlet is blocked by default and should be blocked for obvious reasons.
Since your question is general, I will try to answer generally and on a high level.
There are two possible options I can think of:
1. make a servlet to retrieve the last 3 news component information and expose them as JSON. Then send an AJAX request from your browser and change the view accordingly with jquery or your front-end framework of choice.
Advantages: No caching, you'll always get the latest news.
Disadvantages: SEO, if you care about that in this case. Search engines will
not index the news on the page since they are not part of the initial markup (not server-side rendered)
2. Create a service to get the last 3 news component info then render them on your component via HTL or JSP. Basically server-side render them.
Advantages: SEO, same as the reason above.
Disadvantages: You have to invalidate the cache for your page every time a new news component is added to make sure your end users get the latest.
Hope this helps.

tx_news direct link to news entry

it is possible to have a direct path to a special news entry?
example:
my link is: http://www.domain.de/start/topnewsdetail/news/really-long-name-of-news-entry.html
and it would be nice to have
http://www.domain.de/newsEntry.html.
Can someone give a hint?
it is a little bit complicated if you want a general automatic solution.
you can do it by hand if you insert pages of type 'external url' where you insert the long path as external url.
with realurl you have problems as realurl at least will use one path segment for the page with the detail view before the last segment which is for identifying the news record. AFAIK coolurl can ommit the path segemnt for the page.
on the other hand: make sure the news identification (title, subtitle?) is unique and does not collide with pathes for normal pages.
at last you can use .htaccess rewrites, but that needs to differentiate between short urls for news and short urls for top-level pages. So those urls will show the page, those urls are not generated inside of TYPO3 and so nowhere used (except manual)
this EXT. adds a custom link to records like system category or news:
https://typo3.org/extensions/repository/view/recordlink
It'S deployed for TYPO3 6.2 but perhabs it'S helpful to create an own EXT.?

Entity Property in URL and SEO

I have coded my ASP.NET MVC application in a way that allows stored entities to be retrieved via a friendly name in the URL, for example:
www.mysite.com/artists/james-brown/songs
Where james-brown is a URL friendly string stored on my Artist entity.
Now imagine I add an artist that no one has heard of before, and no one ever navigated to that artist's songs page.
How would Google/Yahoo/Other Search Engines know that my site does indeed have songs for that unknown artist.
Do I create a sitemap and maintain it through code as I add / remove artists?
There are few defined known ways to make the new links visible to search engine world.
XML and HTML Sitemap:
Add it to sitemap and submit it through webmaster tools.
HTML sitemaps are another way to achieve it. If your site has footer sitemap, you can add it to them.
Internal Links
Create internal links from your high ranking pages or highly crawled pages to the new pages. Google and other search engines tend to crawl pages where the content changes frequently. So if you have a refreshed content pages, try adding it to those pages and chances are high for those pages to be discovered quickly.
External Links
Create links from external blogs, company blogs and sites like pagetube.org which can help it to be discovered.
Yeah just add them to either sitemap, internal or even external links

How to setup redirects for a large number of posts

I am working on a major site migration for alpinezone.com . As part of that migration, I moved all the news articles from vbulletin into wordpress cms. The vbulletin articles were previousyl pulled out via a plugin called GARS.
In any event, I have 3400 news articles over the course of five years or so. They are presently in the following format:
news.alpinezone.com/12345
If the title of the news article was "Sugarloaf Sets World Record" then the new location will be
alpinezone.com/sugarloaf-sets-world-record/
Is there a way for me to automate creating the necessary redirects that take the title from the literal page 12345 and convert into a URL?
Finally; the additional trick is that since I did a VB upgrade the existing news articles no longer show up. So going to news.alpinezone.com/12345 won't show anything right now, you need to pull up the forum thread (which is typically hidden) by taking that identifier and going to http://forums.alpinezone.com/showthread.php?12345 to see the actual title. I can pull all this from the WP database, (since all the posts are from a user AlpineZone News).
Any ideas? I'm fairly new to this and the added complexity of subdomains is somethign I am trying to figure out. Thx!
you could make your own showthread.php file in the correct location it was previously located.
have it use the passed id, retrieve the associated record from your database.
Construct the new url by turning the title to lowercase and changing spaces to - and do a redirect via header('Location: new url here');