? ? Pending

User tests: Successful: Unsuccessful:

avatar pe7er
pe7er
26 Jun 2016

Pull Request for Issue #10191 + #10282. This PR adds a link to the front-end view of a single article in the Article: Edit view. It only works for saved articles (that have an ID) and the links are non-SEF links.

Testing Instructions

Before the PR

Go to Content > Articles > open an article. On top it says "Articles: Edit"
administrator-edit_article_before

After the PR

Go to Content > Articles > open an article. On top it says "Articles: Edit" plus a new icon.
A click on that icon will open the article in the front-end in a new window.
administrator-edit_article_after

avatar pe7er pe7er - open - 26 Jun 2016
avatar pe7er pe7er - change - 26 Jun 2016
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 26 Jun 2016
Labels Added: ? ?
avatar joomla-cms-bot joomla-cms-bot - change - 26 Jun 2016
Labels Added: ? ?
avatar pe7er pe7er - change - 26 Jun 2016
The description was changed
avatar pe7er pe7er - change - 26 Jun 2016
The description was changed
avatar pe7er
pe7er - comment - 26 Jun 2016

btw: I've used the word "item" in the language file, and not "article".
I'll create two similar PRs for com_contact + com_newsfeeds soon, so we can reuse the language string...

avatar brianteeman brianteeman - change - 26 Jun 2016
Category Administration Language & Strings UI/UX
avatar brianteeman brianteeman - change - 26 Jun 2016
Labels
avatar brianteeman brianteeman - change - 26 Jun 2016
Labels
avatar brianteeman brianteeman - change - 26 Jun 2016
Title
Edit Article - Link to front-end
Edit Article - Link to front-end
avatar brianteeman
brianteeman - comment - 26 Jun 2016

It only works for saved articles (that have an ID)

Not 100% true - it only works for saved articles that have a status of published or archived.

Also the icon needs a bit of css love as the colour has little contrast to the background which is an a11y fail and the onhover is almost the same as the background


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/10932.

avatar infograf768
infograf768 - comment - 26 Jun 2016

This PR is wrong as I explained here:
#10282 (comment)

avatar infograf768
infograf768 - comment - 26 Jun 2016

FYI, this is the way we got the correct link using editor-xtd/article
6c97f43

avatar infograf768
infograf768 - comment - 27 Jun 2016

Also we get a fatal error in multilang

( ! ) Fatal error: Call to undefined function array_column() in /Applications/MAMP/htdocs/testwindows/trunkgitnew/plugins/system/redirect/redirect.php on line 170

avatar infograf768
infograf768 - comment - 27 Jun 2016

@pe7er

Here is a diff which will work when sef on or off, in multilang or not.
As JRoute does not work yet from admin to site, it will use a non-sef url.
I guess it is not very important as it is only to check the look of the article in frontend.
The Itemid is the one of the Home page for the language used by the item.
It will be very easy to modify when JRoute will work in admin.
No new lang string necessary as it picks the article title.

diff --git a/administrator/components/com_content/views/article/view.html.php b/administrator/components/com_content/views/article/view.html.php
index 9f58183..9e67513 100644
--- a/administrator/components/com_content/views/article/view.html.php
+++ b/administrator/components/com_content/views/article/view.html.php
@@ -87,6 +87,64 @@
        $canDo = $this->canDo;

+       $linkArticle = "";
+
+       if (!$isNew)
+       {
+            $lang = '';
+            $sef  = '';
+
+            // Get the home Itemid for the language
+           $db = JFactory::getDbo();
+           $query = $db->getQuery(true);
+
+           $query->select('id')
+               ->from($db->qn('#__menu'))
+               ->where($db->qn('home') . '= 1')
+               ->where($db->qn('published') . '= 1')
+               ->where($db->qn('client_id') . '= 0');
+
+           if (JLanguageMultilang::isEnabled())
+           {
+               $query->where($db->qn('language') . ' = ' . $db->q($this->item->language));
+           }
+           else
+           {
+               $query->where($db->qn('language') . ' = ' . $db->q('*'));
+           }
+           $db->setQuery($query);
+
+           $Itemid = '&Itemid=' . (int) $db->loadResult();
+
+           if ($this->item->language && JLanguageMultilang::isEnabled())
+           {
+               // Get the sef prefix for the language
+               $query->clear()
+                   ->select('sef')
+                   ->from($db->qn('#__languages'))
+                   ->where($db->qn('published') . '= 1')
+                   ->where($db->qn('lang_code') . ' = ' . $db->q($this->item->language));
+               $db->setQuery($query);
+
+               $sef = $db->loadResult();
+
+               if ($this->item->language != '*')
+               {
+                   $lang = '&lang=' . $sef;
+               }
+               else
+               {
+                   $lang = "";
+               }
+           }
+
+           $linkArticle = '<a href="' .
+                   JURI::root() . 'index.php?option=com_content&amp;view=article&amp;id=' . (int) $this->item->id
+                   . '&amp;catid=' . (int) $this->item->catid . $lang . $Itemid . '" title="' . $this->item->title
+                   . '" target="_blank"><span class="icon-out-2"></span></a>';
+       }
+
        JToolbarHelper::title(
-           JText::_('COM_CONTENT_PAGE_' . ($checkedOut ? 'VIEW_ARTICLE' : ($isNew ? 'ADD_ARTICLE' : 'EDIT_ARTICLE'))),
+           JText::_('COM_CONTENT_PAGE_' . ($checkedOut ? 'VIEW_ARTICLE' : ($isNew ? 'ADD_ARTICLE' : 'EDIT_ARTICLE')))
+           . " " . $linkArticle,
            'pencil-2 article-add'
        );
avatar mbabker
mbabker - comment - 27 Jun 2016

@infograf768 log a separate (release blocking) issue for the array_column() error. It's unrelated to this patch and it is a release blocker because per the documentation it only exists as of PHP 5.5. Either a polyfill for the method needs to be implemented (add the symfony/polyfill-php55 package via Composer) or the code rewritten to not use that function.

avatar infograf768
infograf768 - comment - 27 Jun 2016

@mbabker
Done

avatar C-Lodder
C-Lodder - comment - 5 Jul 2016

Good idea but I am not a fan of the approach. Having a single icon next to the Toolbar title has no real meaning so people will not know what it does.

I think adding it below the textarea as show in the screenshot below would be better. The icon for the "toggle editor" button also really needs to change too:

screeny

An alert should also appear if the article requires saving before hand

avatar ggppdk
ggppdk - comment - 5 Jul 2016

That looks like you are previewing only description ?

but also i agree that an icon next to "Page title" is not best choice ?

  • there should be a new button next to the buttions "save" , "close" etc
avatar brianteeman
brianteeman - comment - 5 Jul 2016

I agree about the icon - I will see what I can find (for another PR)

Brian Teeman
Co-founder Joomla! and OpenSourceMatters Inc.
http://brian.teeman.net/

avatar killoltailored killoltailored - test_item - 8 Jul 2016 - Tested successfully
avatar killoltailored
killoltailored - comment - 8 Jul 2016

I have tested this item successfully on b8805e7


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/10932.

avatar TasolJamal TasolJamal - test_item - 9 Jul 2016 - Tested successfully
avatar TasolJamal
TasolJamal - comment - 9 Jul 2016

I have tested this item successfully on b8805e7


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/10932.

avatar gunjanpatel gunjanpatel - change - 11 Jul 2016
Status Pending Ready to Commit
avatar gunjanpatel
gunjanpatel - comment - 11 Jul 2016

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/10932.

avatar joomla-cms-bot joomla-cms-bot - change - 11 Jul 2016
Labels Added: ?
avatar brianteeman brianteeman - change - 11 Jul 2016
Status Ready to Commit Pending
Labels
avatar brianteeman
brianteeman - comment - 11 Jul 2016

Sorry I am removing the RTC at this time.


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/10932.

avatar joomla-cms-bot joomla-cms-bot - change - 11 Jul 2016
Labels Removed: ?
avatar infograf768
infograf768 - comment - 11 Jul 2016

Indeed. Test were not done correctly. Once more, the language has to be included in the link... !!! See above.

avatar infograf768
infograf768 - comment - 11 Jul 2016

Once #11060 is merged, the right code would be:

diff --git a/administrator/components/com_content/views/article/view.html.php b/administrator/components/com_content/views/article/view.html.php
index 9f58183..6bc8cce 100644
--- a/administrator/components/com_content/views/article/view.html.php
+++ b/administrator/components/com_content/views/article/view.html.php
@@ -87,6 +87,65 @@
        $canDo = $this->canDo;

+       $link        = "";
+       $linkArticle = "";
+
+       if (!$isNew)
+       {
+            $lang = '';
+            $sef  = '';
+
+            // Get the home Itemid for the language
+           $db = JFactory::getDbo();
+           $query = $db->getQuery(true);
+
+           $query->select('id')
+               ->from($db->qn('#__menu'))
+               ->where($db->qn('home') . '= 1')
+               ->where($db->qn('published') . '= 1')
+               ->where($db->qn('client_id') . '= 0');
+
+           if (JLanguageMultilang::isEnabled())
+           {
+               $query->where($db->qn('language') . ' = ' . $db->q($this->item->language));
+           }
+           else
+           {
+               $query->where($db->qn('language') . ' = ' . $db->q('*'));
+           }
+           $db->setQuery($query);
+
+           $Itemid = '&amp;Itemid=' . (int) $db->loadResult();
+
+           if ($this->item->language && JLanguageMultilang::isEnabled())
+           {
+               // Get the sef prefix for the language
+               $query->clear()
+                   ->select('sef')
+                   ->from($db->qn('#__languages'))
+                   ->where($db->qn('published') . '= 1')
+                   ->where($db->qn('lang_code') . ' = ' . $db->q($this->item->language));
+               $db->setQuery($query);
+
+               $sef = $db->loadResult();
+
+               if ($this->item->language != '*')
+               {
+                   $lang = '&amp;lang=' . $sef;
+               }
+               else
+               {
+                   $lang = "";
+               }
+           }
+
+           $link = JRoute::_('index.php?option=com_content&amp;view=article&amp;id=' . (int) $this->item->id
+                   . '&amp;catid=' . (int) $this->item->catid . $lang . $Itemid , true, null, 'site');
+           $linkArticle = '<a href="' . $link . '" title="' . $this->item->title
+                   . '" target="_blank"><span class="icon-out-2"></span></a>';
+       }
+
        JToolbarHelper::title(
-           JText::_('COM_CONTENT_PAGE_' . ($checkedOut ? 'VIEW_ARTICLE' : ($isNew ? 'ADD_ARTICLE' : 'EDIT_ARTICLE'))),
+           JText::_('COM_CONTENT_PAGE_' . ($checkedOut ? 'VIEW_ARTICLE' : ($isNew ? 'ADD_ARTICLE' : 'EDIT_ARTICLE')))
+           . " " . $linkArticle,
            'pencil-2 article-add'
        );
avatar infograf768
infograf768 - comment - 11 Jul 2016

@andrepereiradasilva
As you see in my code above, I did not need
JRoute::_(ContentHelperRoute::getArticleRoute

avatar andrepereiradasilva
andrepereiradasilva - comment - 11 Jul 2016

@andrepereiradasilva
As you see in my code above, I did not need
JRoute::_(ContentHelperRoute::getArticleRoute

true, but if already exists why not just reuse it like i did in my comment?

avatar infograf768
infograf768 - comment - 11 Jul 2016

Indeed. :)

avatar infograf768
infograf768 - comment - 12 Jul 2016

This would be enough:|

        $linkArticle = "";
        $url         = "";

        if (!$isNew)
        {
            JLoader::register('ContentHelperRoute', JPATH_SITE . '/components/com_content/helpers/route.php');
            $url = JRoute::_(ContentHelperRoute::getArticleRoute((int) $this->item->id, (int) $this->item->catid, $this->item->language), true, null, 'site');
            $linkArticle = '<a href="' . $url . '" title="' . htmlspecialchars($this->item->title, ENT_COMPAT, 'UTF-8') . '" target="_blank"><span class="icon-out-2"></span></a>';
        }

        JToolbarHelper::title(
            JText::_('COM_CONTENT_PAGE_' . ($checkedOut ? 'VIEW_ARTICLE' : ($isNew ? 'ADD_ARTICLE' : 'EDIT_ARTICLE')))
            . " " . $linkArticle,
            'pencil-2 article-add'
        );
avatar NeerajTailored NeerajTailored - test_item - 21 Jul 2016 - Tested successfully
avatar NeerajTailored
NeerajTailored - comment - 21 Jul 2016

I have tested this item successfully on b8805e7


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/10932.

avatar brianteeman brianteeman - change - 10 Sep 2016
Status Pending Information Required
Labels
avatar brianteeman
brianteeman - comment - 10 Sep 2016

@pe7er will you be updating this to work with multilingual as mentioned by @infograf768 above?


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/10932.

avatar pe7er
pe7er - comment - 21 Sep 2016

Actually, I prefer @C-Lodder his approach, with adding a button below the article.
Could you please create a PR for your suggestion?

avatar C-Lodder
C-Lodder - comment - 21 Sep 2016

I can do tonight. Would it not be best to submit a PR against the 3.7 branch so that #11060 will be merged too?

avatar brianteeman
brianteeman - comment - 9 Oct 2016

@c-lodder any update?


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/10932.

avatar C-Lodder
C-Lodder - comment - 9 Oct 2016

@brianteeman - will do now. So I assume this is going into staging then?

avatar C-Lodder
C-Lodder - comment - 9 Oct 2016

PR: #12367

avatar brianteeman
brianteeman - comment - 4 Dec 2016

@pe7er not sure what the status is on this PR - can you clarify please


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/10932.

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 8 Jan 2017

I have tested this item ? unsuccessfully on b8805e7


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/10932.

avatar franz-wohlkoenig franz-wohlkoenig - test_item - 8 Jan 2017 - Tested unsuccessfully
avatar AndySDH
AndySDH - comment - 22 Feb 2017

How comes this was never implemented? Seems like a no-brainer.

avatar C-Lodder
C-Lodder - comment - 22 Feb 2017

@AndySDH - It's already in J4.x (display in a modal) so people are more than welcome to copy it into 3.x

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 22 Feb 2017

@C-Lodder haven't seen the new "Preview"-Button before.

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 22 Feb 2017

@C-Lodder i meant: Havent seen before your comment;-)

avatar franz-wohlkoenig franz-wohlkoenig - change - 6 Apr 2017
The description was changed
Status Information Required Needs Review
avatar joomla-cms-bot joomla-cms-bot - change - 6 Apr 2017
Category Administration Language & Strings UI/UX Administration com_content Language & Strings UI/UX
avatar joomla-cms-bot joomla-cms-bot - edited - 6 Apr 2017
avatar roland-d
roland-d - comment - 13 May 2017

@pe7er I am going to close this issue as it is already implemented in Joomla 4 and Joomla 4 is on the horizon. This may not be worth the effort.

avatar roland-d roland-d - change - 13 May 2017
Status Needs Review Closed
Closed_Date 0000-00-00 00:00:00 2017-05-13 20:12:27
Closed_By roland-d
avatar roland-d roland-d - close - 13 May 2017
avatar pe7er
pe7er - comment - 15 May 2017

Ok, thanks @roland-d

avatar sanek4life
sanek4life - comment - 3 Feb 2020

@roland-d @pe7er Hello from 2020! Almost 3 years have passed, and we still do not see this function, just as we do not even see the beta version of Joomla 4.

How many articles could be created using this feature over the last 3 years...

Add a Comment

Login with GitHub to post a comment