#1 2014-07-28 14:12:52

pclara
Member
Registered: 2014-07-28
Posts: 6

Article specific view ignored

Hello all.

While checking out the new 1.0.7 i have stumbeled upon this bug:
If i assign a specific view to a single article on a page, the default article view is used instead of the specified one.

Here is how i solved it in application/libraries/Tagmanager/Article.php

private static function find_and_parse_article_view(FTL_Binding $tag, $article)
	{
		// Registered page
		$page = self::registry('page');

		// Local articles
		$articles = $tag->get('articles');

		// Try to get the view defined for article
		$tag_view = $tag->getAttribute('view');

		// Force first the view defined by the tag
		if ( ! empty($tag_view))
				$article['view'] = $tag_view;

		// Default page article view
		if (empty($article['view']))
			if (count($articles) == 1)
					$article['view'] = $page['article_view'];
				else
					$article['view'] = $page['article_list_view'];

		// Default article view
		if (empty($article['view']))
			$article['view'] = Theme::get_default_view('article');

		// View path
		$view_path = Theme::get_theme_path().'views/'.$article['view'].EXT;

		// Return the Ionize default's theme view
		if ( ! file_exists($view_path))
		{
			$view_path = Theme::get_theme_path().'views/'.Theme::get_default_view('article').EXT;
			if ( ! file_exists($view_path))
				$view_path = APPPATH.'views/'.Theme::get_default_view('article').EXT;
		}

		return $tag->parse_as_nested(file_get_contents($view_path));
	}

I hope my contribution can be useful.

Offline

#2 2015-06-21 20:44:20

Dp.hermes
Member
From: Paris - France
Registered: 2013-07-05
Posts: 44

Re: Article specific view ignored

Hi there,

I noticed this bug as well.

Unfortunately your solution doesn't work for me...
My article is still appearing in the default view.

Do you have an idea ?

Offline

#3 2015-06-21 22:40:44

daniel
Member
Registered: 2014-02-28
Posts: 71

Re: Article specific view ignored

Maybe an error in the view?

Offline

#4 2015-06-22 10:14:11

Dp.hermes
Member
From: Paris - France
Registered: 2013-07-05
Posts: 44

Re: Article specific view ignored

daniel wrote:

Maybe an error in the view?

I don't think so... The view is quite simple, and moreover the article appears in the page with its default view, not the specific one.

Offline

#5 2015-06-22 13:21:56

daniel
Member
Registered: 2014-02-28
Posts: 71

Re: Article specific view ignored

It happens often to me, that i forget a letter and so things do not work as expected.
So if i have a normal view, i write

<ion:articles:article type="mytype">

but if a have a single view, i write only

<ion:article>

(Singular and without type). And - I call the URL of the article and not the page.
If the single-view-setting does not work as expected, i think, there should be a typo in the view.

Offline

#6 2015-06-22 16:28:07

Dp.hermes
Member
From: Paris - France
Registered: 2013-07-05
Posts: 44

Re: Article specific view ignored

Yes, it can of course happen to misspell a word or so.

The thing is though that I'm not having problem with the types, but with the views.
On the website I'm developing now I have a lot of different types of articles that work pretty well.

But what isn't working is the view of the article.
E.g. : If you click on your page blue file in Ionize, you can see your articles, for each you can set a type and/or a view.
Everything works perfectly for page views, but not for the article view.
Every article for which I have set a view appears with the default view.

Do you see what I mean ?

Of course I could use article types, to have a different appearance for this article, but the problem with this is that your articles aren't in the good order then... The article with this type will appear or before, or after the others...

Thanks for your answer though smile

Offline

#7 2015-06-22 19:28:21

daniel
Member
Registered: 2014-02-28
Posts: 71

Re: Article specific view ignored

Normally i set the view only in the page-settings. In Article-settings there are no view-options, only type.
If i set a "Single Article View" in Page-Settings, every Article linked with this Page will be displayed with the specified view, if called via the article-URL
Views

If you have a view-option for every single article, i would see a screenshot of it, because i cannot find it.

Last edited by daniel (2015-06-22 19:29:11)

Offline

#8 2015-06-23 13:55:56

Dp.hermes
Member
From: Paris - France
Registered: 2013-07-05
Posts: 44

Re: Article specific view ignored

Well yeah,

If you click on your file page (the blue one), and then in the article you have this (which normally gives your the opportunity to set a specific view to each article :
ScreenshotCMS

Which is normally way more practical than setting a type cause in your code you can't do differently than calling one type of article after another. Impossible this way to do something like :
"Default view for article 1"
"Specific view 1 for article 2"
"Default view for article 3"
"Specific view 2 for article 4"
"Default view for article 5"

Offline

#9 2015-06-23 23:58:27

daniel
Member
Registered: 2014-02-28
Posts: 71

Re: Article specific view ignored

The manual says

Since Ionize 0.9.9, articles views are not really used anymore.
Pages views are enough to build most of the websites without the need of using dedicated articles views. The more views you use, the more complex will be the edition of the website. Keep it simple !

I think, this function will not be maintained anymore.

To receive different views for different articles we use normally the article types so we have only one file, that covers all types

<ion:articles:article type="my-type-1">
	blah
</ion:articles:article>

<ion:articles:article type="my-type-2">
	bluh
</ion:articles:article>

Offline

#10 2015-06-26 13:51:59

daniel
Member
Registered: 2014-02-28
Posts: 71

Re: Article specific view ignored

But ... maybe you missed only render="true"

<ion:article render="true" />

http://doc.ionizecms.com/en/tags-reference/article-tags

Offline

#11 2017-09-14 12:18:12

KoniRus34
Member
From: Italy - Russia
Registered: 2014-12-11
Posts: 8

Re: Article specific view ignored

Check if last line is

if ( is_null($article_view))

and not

if ( ! is_null($article_view))

File: /application/libraries/Tagmanager/Article.php

private static function find_and_parse_article_view(FTL_Binding $tag, $article)
	{
		// Registered page
		$page = self::registry('page');

		// Local articles
		$articles = $tag->get('articles');

		// Try to get the view defined for article
		$tag_view = $tag->getAttribute('view');
		$article_view = ! is_null($tag_view) ? $tag_view : ( ! empty($article['view']) ? $article['view'] : NULL);

		if ( ! is_null($article_view))

Last edited by KoniRus34 (2017-09-14 12:19:36)

Offline

What's Ionize ?

Ionize is an Open Source Content Management System created by webdesigners for webdesigners.

Created and maintained by Partikule and Toopixel, Ionize wants to be the easiest and most powerful CMS.

Can I help ?

Because talent is nothing without involvement, we are looking for motivated coders and webdesigners to join the project team.

Resources

Website : ionizecms.com
Documentation : doc.ionizecms.com

Development : Ionize on GitHub
Translations : Ionize Translations