I need help inserting data on table "articles"

Hi, everyone.

I am new to this list. As i can not speak french (well, i can try to speak french, but definitely i can not write it…), i hope you will forgive me for writing this mail in english…

Let me introduce myself briefly: I am a relatively new spip user (you can read this as « noob »)from Galicia, Spain. I am also a linux/unix sysadmin, and some kind of… « bad programmer ». A friend of mine asked me to write a plugin that allowed spip users to create « groups » and write « group-based blogs ». And i said « sure, i will try ».

In order to understand how to do this, i started looking at the code of other plugins, trying to figure out how they worked. Particularly, i found one (« Tickets, suivi de bugs », by ARNO*. If you are reading this, thank you) that really helped me out to realize what kind of things i could do, and how. Later, i went to #spip on IRC, where a lot of great people helped me every time i logged in and asked how to do something. Again, if any of you are subscribed to this list, thank you from « jchaves » :slight_smile: !.

So, now i am writing this plugin. So far, I created these tables:

spip_blogs_blogs: with the fields « id_blog »,« name », « style », « title »

spip_blogs_permisos (« permissions »): it has the fields « id_permission »(just a key, not really relevant), « id_auteur », « id_group », and « role » (which is an integer, « 5 » meaning admin, « 4 » author, etc.)

It works like this: imagine there is an entry in « spip_blogs_blogs » with id_blog=1, name=« myblog », style=« some_style », title=« My Blog ». And there is an entry in spip_blogs_permisos like this: id_permission=1, id_auteur=1, id_group=1, role=5.

It means that auteur 1 (let’s call him Adam) is the « administrator » of the blog « My Blog », so he can add new users to « My Blog », and such.

All this is already implemented. There are private pages that allow admins to invite people to their blogs, change blog title, blog style… everything. I created some simple pages that let you go to URL http://my.spip-site.net/?page=blogs&name_blog=myblog (or even http://my.spip-site.net/blogs/myblog , by editing .htaccess).

In this page, there is a BOUCLE like this (it is actually a bit more complicated, but it does essentially this):
<BOUCLE_blog(BLOGS_BLOGS){name = #NAME_BLOG} >

#TITLE

#TITLE

#TITRE #INTRODUCTION

The idea was to alter the table « spip_articles », adding the field « id_blog » (and i did it, already). So, if a user writes an article that will go on the « general page » (i mean « sommaire.html », etc), this field will be empty for that article (or, perhaps, contain « 0 », or « NULL », or something).
But if the user wants to write an article for his/her blog, this field will contain that blog’s « id_blog ». So, if Adam wants to write an article to be published on « My Blog », this field will have to contain « 1 ».

Keep in mind that i also will modify the boucles on page « sommaire.html » to just include articles with empty « id_blog » (or id_blog=0, or something)…

Aaaand… here comes the big problem: i have no idea on how to do this. By now, i tried: (keep in mind that « entrada » is, more or less, the spanish word for « a blog post »)

  • copy the file « spip/prive/editer/article.html » to « plugins/blogs/prive/editer/editar_entrada.html »
  • copy « ecrire/exec/articles_edit.php » to « plugins/blogs/exec/editar_entrada.php » (and modify it, to have proper function names)
  • copy aditional formulaires and such, needed for this to work… changing their names, to avoid conflicts…
  • go to URL « http://my.spip-site.net/ecrire/?exec=editar_entrada&new=oui&id_blog=1 »

It does non work yet, because i thought this surely is not the best way to do it, and i stoped messing with it. Furthermore, this page « ?exec=editar_entrada » shows table fields that « ?exec=articles_edit » will not show (like « Sur-titre », « Chapeau »…). It shows the formulaire and all, but does not really insert anything in the tables yet.

So… Anyone can imagine a way to do this? I just need a way to insert this « id_blog » when needed, but i am stuck at this point…

I think i explained it all, but if you need further information about what i have done, or whatever, let me know.

Thanks in advance!

PS: By now, this plugin is a « pre-alpha work in progress », and is of course a bit messy, buggy, and untranslated and such. When it is finished, i will of course release it, if anyone is interested.

PS2: Now that i am reading this mail i just wrote, it looks more like someting to be sent to a « developers list ». But i am afraid it will interfer with the conversations about the development of spip itself if i send it to spip-dev. I am not sure where to send it… If any of you think this would fit better there, just let me know, and i will send it there.


Saúde,

Chaves.

hi Jose,
welcome on board

Let me introduce myself briefly: I am a relatively new spip user (you can
read this as "noob")from Galicia, Spain. I am also a linux/unix sysadmin,

do you know there is an es liste ?
http://listes.rezo.net/mailman/listinfo/spip-es

plugin that allowed spip users to create "groups" and write "group-based
blogs". And i said "sure, i will try".

what do you (or your friend ) want exactly ?
could you detail whith an sample ?

for example as i understand, it could be a domain www.myproject.com and
a group of people who want to share things about cats want a blog . You
build a cats.myproject.com with a blog skin and the could publish cats stories.
An other group could create a blog about dogs.

Ben.

2009/7/8 Ben. <ben@rezo.net>

hi Jose,
welcome on board

Let me introduce myself briefly: I am a relatively new spip user (you can
read this as « noob »)from Galicia, Spain. I am also a linux/unix sysadmin,

do you know there is an es liste ?
http://listes.rezo.net/mailman/listinfo/spip-es

Oops, i didnt know. thanks for the info.

plugin that allowed spip users to create « groups » and write « group-based
blogs ». And i said « sure, i will try ».

what do you (or your friend ) want exactly ?
could you detail whith an sample ?

for example as i understand, it could be a domain www.myproject.com and
a group of people who want to share things about cats want a blog . You
build a cats.myproject.com with a blog skin and the could publish cats stories.
An other group could create a blog about dogs.

I am not 100% sure, but i think he is part of a « federation » of « associations of students parents ». They have a web-site for this association (which i think is -or will be- running SPIP). So, i think the goal is having a main site for this « federation », and plus, every association being able of having a « blog » for their internal issues, or whatever. Like:

http://site-of-federation.net/ for every user to write there
http://site-of-federation.net/blogs/association1 where just members of this association can write…

Anyway, the concept is somehow « universal ». Imagine http://football-entusiasts.net and http://football-entusiasts.net/blogs/real-madrid-fans , http://football-entusiasts.net/blogs/manchester_united … Or whatever.

Well, that is the idea… Thanks for your response!

Ben.


Saúde,

Chaves.