Forums / Cotonti / Extensions / Support / Make news editable on homepage

foxhound
#1 2009-11-22 23:17
I am trying to edit the news plugin which comes with Cotonti so that there is again the possibility for admins to edit any articles which are displayed on the homepage. So, you do not have to go to the page itself first.
So, at the moment I am editing the news.function.php in the news plugin folder and added this (and a lot of other tries but I think this is the best and I should almost be there):
	// Added to enable editing of pages on homepage
	if ($usr['isadmin'] || $usr['id'] == $pag['page_ownerid'])
	{
	$news-> assign("PAGE_ROW_ADMIN_EDIT", "<a href=\"".sed_url('page', 'm=edit&id='.$pag['page_id'].'&r=list')."\">".$L['Edit'].'</a>');
	}

But, it generates an error:
Fatal error: Call to a member function assign() on a non-object in /home/armaholi/public_html/testers/armaholictest/plugins/news/inc/news.functions.php on line 55

So, after some more tinkering I figured I needed to add this:
	// Added to enable editing of pages on homepage
	list($usr['auth_read'], $usr['auth_write'], $usr['isadmin']) = sed_auth('page', 'any');
sed_block($usr['auth_read']);

	// Added to enable editing of pages on homepage
	list($usr['auth_read'], $usr['auth_write'], $usr['isadmin'], $usr['auth_download']) = sed_auth('page', $pag['page_cat'], 'RWA1'); 
As it is refering to a member (rights?).
But still no joy, the admin can still not edit the news on the homepage.
Anyone able and willing to tell me what I am doing wrong?
<img src="http://www.armaholic.com/datas/thumbs/green-sea-battalion-uniforms-version-03-preview_4.jpg" alt="green-sea-battalion-uniforms-version-03-" />
musiconly
#2 2009-11-24 01:47
I solved this the easiest way I knew :)
skins/yourkin/plugins/news.tpl

add somewhere in it, between <!-- BEGIN: PAGE_ROW --> <!-- END: PAGE_ROW -->:
<!-- IF {PHP.usr.profile.user_maingrp} == '5' -->
	<a href="page.php?m=edit&id={PAGE_ROW_ID}&r=list">Edit</a>
<!-- ENDIF -->

Power of logic blocks :D
pieter
#3 2009-11-24 02:39
I love logic blocks. You can almost everything you want.
Only finding the right variable is my problem.

Is there a list with the variables?
Also is there a lost of all TPL tags?
Because in http://www.cotonti.com/plug.php?e=tpltags there are some missing.
Like news.tpl, index.tpl, ..
... can we help you ...
Kort
#4 2009-11-24 05:47
<!-- IF {PHP.usr.isadmin} -->
	<a href="page.php?m=edit&id={PAGE_ROW_ID}&r=list">Edit</a>
<!-- ENDIF -->
SED.by - создание сайтов, разработка плагинов и тем для Котонти
foxhound
#5 2009-11-24 16:49
Thanks so much for all replies :)

But, none of the above works, I added both ways to my news.tpl in the /skins/Blaster07/plugins/ folder but still there is no edit option for admins.
And before anyone asks. Yes, I am an admin there. :)

Here is how the tpl looks now:
<!-- BEGIN: NEWS -->
<!--Seditio Skin T3 Blaster 07 Copyright © 2007 T3-Design.Com. All rights Reserved. -->

<!-- BEGIN: PAGE_ROW -->

<div class="{PAGE_ROW_AUTHOR}">
	<div id="{PAGE_ROW_KEY}" >
		<div style="float:left; height:25px; padding:4px 0 3px 57px">&nbsp; <a href="{PAGE_ROW_URL}">{PAGE_ROW_SHORTTITLE}</a> </div><div style="float:right; height:25px; padding:4px 0 3px 0px">{PAGE_ROW_CATICON}</div><div style="clear: both;"></div>
	</div>
	<div id="fondonews">
		<div style="float:left;"> {PAGE_ROW_CATPATH} </div>
		<div style="float:right">{PAGE_ROW_COMMENTS} {PAGE_ROW_ADMIN}</div>
	</div>
<br>{PAGE_ROW_TEXT}<br><br>
	<div id="fondonews">
		<span style="float:left;">Written on {PAGE_ROW_DATE} by {PAGE_ROW_OWNER}</span>
		<span style="float:right">test2</span>
<!-- IF {PHP.usr.isadmin} -->
	<a href="page.php?m=edit&id={PAGE_ROW_ID}&r=list">Edit</a>
<!-- ENDIF -->

<!-- IF {PHP.usr.profile.user_maingrp} == '42' -->
	<a href="page.php?m=edit&id={PAGE_ROW_ID}&r=list">Edit</a>
<!-- ENDIF -->
		
		
		
	</div>
</div>

<!-- END: PAGE_ROW -->
<!-- BEGIN: HEADLINES_ROW -->
<div class="{PAGE_ROW_ODDEVEN}">{PAGE_ROW_DATE} : {PAGE_ROW_CATPATH_IDX} {PHP.cfg.separator} <a href="{PAGE_ROW_URL_IDX}">{PAGE_ROW_SHORTTITLE}</a></div>
<!-- END: HEADLINES_ROW -->

<div class="paging">{PAGE_PAGEPREV} {PAGE_PAGENAV} {PAGE_PAGENEXT}</div>

<!--Seditio Skin T3 Blaster 07 Copyright © 2007 T3-Design.Com. All rights Reserved. -->
<!-- END: NEWS -->



[edit]
"Test2" is only just there for making sure to me I am editing the correct tpl. Same as the location, this is just to see if i can get it to work, after that I put it in a <div>


[edit2]
Uhm, no idea, but now it works correct.
But only by using the way how musiconly told how he did it. That default "isadmin" block does not work. Maybe for that one you need to be user=1?
<img src="http://www.armaholic.com/datas/thumbs/green-sea-battalion-uniforms-version-03-preview_4.jpg" alt="green-sea-battalion-uniforms-version-03-" />
This post was edited by foxhound (2009-11-24 16:58, 14 years ago)
Kort
#6 2009-11-24 19:22
Just tested
<!-- IF {PHP.usr.isadmin} -->
	<a href="page.php?m=edit&id={PAGE_ROW_ID}&r=list">Edit</a>
<!-- ENDIF -->
in plugins/news.tpl on a live site under 0.6.5. Works fine (as it should).
1. Try to login as admin
or
2. Group "42" has no admin privileges
SED.by - создание сайтов, разработка плагинов и тем для Котонти
This post was edited by Kort (2009-11-24 19:57, 14 years ago)
foxhound
#7 2009-11-24 20:35
I have just logged into my website with the main admin account (user 1). I checked all rights and this user has all rights set to allow.
If I than add the
<!-- IF {PHP.usr.isadmin} -->
	<a href="page.php?m=edit&id={PAGE_ROW_ID}&r=list">Edit</a>
<!-- ENDIF -->
to my news.tpl there still is no way to edit the news directly.

I am using the latest version of cotonti. Site is not public though, its in maintenance mode.

If you want I can give you acces to the site so you can see it for yourself, you can get the head admin acces info if you want. Just so you can check all rights.
<img src="http://www.armaholic.com/datas/thumbs/green-sea-battalion-uniforms-version-03-preview_4.jpg" alt="green-sea-battalion-uniforms-version-03-" />
Kilandor
#8 2009-11-25 13:57
Goto Others > Disk Cache and Delete the templates cache see if that helps.
foxhound
#9 2009-11-25 17:53
# Kilandor : Goto Others > Disk Cache and Delete the templates cache see if that helps.

Something must be really wrong here, I do not have that option under "other". The only thing I can choose is "Internal cache".
However, I always just manually empty the templates cache (in datas), I guess thats the same right?

I am going to take someones offer and ask him to convert our Seditio DB to Cotonti. Somewhere during the process things go wrong but I have no idea why (I followed the tuts every time step by step to the letter).
<img src="http://www.armaholic.com/datas/thumbs/green-sea-battalion-uniforms-version-03-preview_4.jpg" alt="green-sea-battalion-uniforms-version-03-" />
Kilandor
#10 2009-11-26 03:17
So are you using Seditio or Cotonti then? If Cotonti what version?
foxhound
#11 2009-11-26 03:56
I use Cotonti 0.6.5, that is the latest version. Here you can see for yourself:



[edit]
To explain.
Our live site is still running Seditio, that is where I converted the DB from (or can pick a new one from any time I want to convert that one).
The DB which is currently used is a few months old. Converting the DB is a very long process for me so I choose not to do it every week ;)

We never went live yet with our Cotonti site since we are reworking our whole site as well at the same time, its just a test site running on Cotonti nobody has acces to.
<img src="http://www.armaholic.com/datas/thumbs/green-sea-battalion-uniforms-version-03-preview_4.jpg" alt="green-sea-battalion-uniforms-version-03-" />
This post was edited by foxhound (2009-11-26 04:04, 14 years ago)