Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE OR ALTER PROCEDURE [dbo].amp_getPage
- @url nvarchar(MAX)
- AS
- BEGIN
- -- движок для заполенния amp страниц вида /amp/docs-123123123123
- SET @url = LOWER(@url)
- DECLARE @DOMAIN nvarchar(128) = dbo.as_setting('domain', '')
- DECLARE @code nvarchar(256) = ''
- DECLARE @t1 TABLE(created nvarchar(MAX), [image] nvarchar(MAX), title nvarchar(MAX), microdataLD nvarchar(MAX),
- canonical nvarchar(MAX), header nvarchar(MAX), content nvarchar(MAX), footer nvarchar(MAX)
- )
- DECLARE @id INT
- DECLARE @microData nvarchar(MAX)='', @otherItems nvarchar(MAX) = '', @p1 ExtendedDictionaryParameter
- IF(LEFT(@url,5) = 'blog-') BEGIN
- SET @code = SUBSTRING(@url, 6, len(@url)-5)
- SELECT @id = id FROM as_articles WHERE LOWER(code)=@code AND isPublish=1
- IF(@id>0) BEGIN
- EXEC [dbo].[as_block] @code ='blogArticleMicroData',
- @itemID =@code,
- @parameters = @p1,
- @res =@microData OUTPUT
- EXEC [dbo].[as_block] @code ='blogArticles',
- @itemID ='1000',
- @parameters = @p1,
- @res =@otherItems OUTPUT
- INSERT INTO @t1
- SELECT CONVERT(nvarchar(10), created, 120) created,
- 'https://' +@DOMAIN + isnull([dbo].[rs_resourceLink]('articleBodyImage', art.id, 0), '') image,
- title title,
- 'https://' +@DOMAIN+ '/blog/'+ LOWER(code) canonical,
- @microData microdataLD,
- '<h1>'+title+'</h1>' header,
- '<img src="'+isnull([dbo].[rs_resourceLink]('articleBodyImage', art.id, 0), '')+'" title="'+title+'" alt="'+title+'" />'+ isnull([text1], '') content,
- '<div>
- <a href="'+'https://' +@DOMAIN + '/blog/' + @code+'" target="_blank">Страница-источник на сайте '+@DOMAIN+'</a><br><hr><br>
- <div style="max-width:600px;">'+isnull(@otherItems, '')+'</div>
- </div>' footer
- FROM as_articles art WHERE id = @id
- END
- END
- IF(LEFT(@url,5) = 'docs-') BEGIN
- SET @code = SUBSTRING(@url, 6, len(@url)-5)
- SELECT @id = id FROM kb_articles WHERE LOWER(code)=@code AND isPublish=1
- IF(@id>0) BEGIN
- EXEC [dbo].[as_block] @code ='docArticleMicrodata',
- @itemID =@code,
- @parameters = @p1,
- @res =@microData OUTPUT
- SET @microData = @microData
- EXEC [dbo].[as_block]
- @code ='knowlegdeBaseLinks',
- @itemID = @code,
- @parameters = @p1,
- @res = @otherItems OUTPUT
- INSERT INTO @t1
- SELECT CONVERT(nvarchar(10), created, 120) created,
- 'https://falconspace.ru/content/images/logo-ico/180.png' image,
- title title,
- 'https://' +@DOMAIN+ '/docs/'+ LOWER(code) canonical,
- @microData microdataLD,
- '<h1>'+title+'</h1>' header,
- isnull([text], '') content,
- '<div>
- <a href="'+'https://' +@DOMAIN + '/docs/' + @code+'" target="_blank">Страница-источник на сайте '+@DOMAIN+'</a><br><hr><br>
- <div style="max-width:600px;">'+isnull(@otherItems, '')+'</div>
- </div>' footer
- FROM kb_articles art WHERE id = @id
- END
- END
- SELECT * FROM @t1
- END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement