I need to write a component that have a per profile page where the user can add articles,
and i dont know if I need to create a new table for users, articles, user_articles, or use the native joomla tables??
and if yes how can I override the methods JFactory::getUser(); - and others...
and if yes will i have to create own methods to save sessions, or use the native $user->is_guest() ???, i am confused about that.
There are a couple of ways you could go about this.
First, you really don't need any new tables at all. There isn't any information you need that isn't already being saved in either the user or article tables. If you want to use Joomla articles, then you would need a new view and model for com_content that displays articles by article author. Use the built in front end content entry and make users register before they can submit articles.
The other option is to switch to using K2 for your content display. K2 already has article by author built in so you wouldn't need to do anything. Again, use the built in front end content entry and require registration before submission.
Related
I am new to Joomla component developement and currently fighting with certain basic design patterns!
Lets say, I am developing a component where users can enter simple notes into their personal notebooks.
On calling the view "index.php?option=com_notebook&view=notes" I simply show a list of all note entries of the user. No problem so far, this is working fine.
Now I want to extend my component with the following feature: on opening the view "index.php?option=com_notebook&view=notes", I want to check if the user has already created a notebook before. If yes, I show all note entries, if not, I want to load a different view which contains a form to create a new notebook with certain options.
But how can this be done in a clean way?
For sure, I just can implement the form within the view "notes", but this is not the clean way, isnt it?
I also tried to override the function "display()" of the main controller and set the view manually if no notebook exists. But if I do so, I have to handle all calls to other views of my component manually within the function "display()". To solve this, I created a copy the original implementation from the class "JControllerLegacy" and changed it to my needs - this is working - but is this really the best way to handle problems like this?
So I ask you, what is the best approach to solve this problem?
Thx a lot!
According to me the best solution of your problem is to provide "New" and "Edit" button to your notebook listing page and create edit view of notbook. Same as Joomla has articles and article views.
So, As you mentioned above if use dose not have any notebook then he/she can create a new notebook using that "New" button. when user clicked on "New" button he has blank form where he/she can create new notebook.
here is the example how to create listing and edit view in Joomla. Hope this will help you.
https://docs.joomla.org/J3.x:Developing_an_MVC_Component/Adding_backend_actions
how can I check for a group entity type associated with the user (im using the group module http://drupal.org/project/group) from inside the user-profile.tpl.php template?
I have a use case for new users where I need to check for a group associated with the user, if it does not exist, then I want to show a button with a link to the 'create group' page.
Thanks, im a designer, which is why i need code examples to work with. ive been using the group module as a test and im really liking the functionality as compared to Organic Groups. Only a few small items are keeping me from launching.
I was thinking I could access it from $global_user as Ive done something similar before checking for a particular "role" and doing something. Im just trying to add a simple helper function for new users to be able to create a new group easily.
Im trying to create some new extensions in joomla.
I want to add additional information for each user. I know I could achieve this by creating my own custom user profile plugin and adding additional fields, but this will then add those fields to the users profile page.
I want to show the new fields separately. For example i may have one link on the users page which takes them to there basic information e.g. name, email etc. And another link which shows them the 'additional' fields.
The additional fields will not be personal information, that's why I want to display them separately.
My question is, how do I achieve this? Can I simply add additional fields to each user or will I have to write a completely new component?
UPDATE: I cannot use an existing extension as I want full control over the code. Also, the additional information will NOT be added by the user, it will only be added by admin.
You do not have to display profile fields on the user profile page with the standard user profile You can configure it only to display to the administrator. You simply make different settings for the different forms (there are 4 throughout the cms). Follow the pattern in the core plugin.
In the end I decided it was better to create my own component. Mainly because hacking joomla would be a pest when updates came out and JED did not provide the specific extension that I wanted.
There are probably 2 main way of doing this.
You can create an extension where user fill in the information and it stores the data in separate database table which connects to the #__users table.
You could download an extension from JED for extended profiles. There are non-commercial and commercial extensions so take a look here to see if there is anything that might suit your needs.
Personally I would install a pre-made extension and it will save a lot of work/trial and error.
check this out: http://extensions.joomla.org/extensions/clients-a-communities/user-management
If you have added or changed any coding like adding fields to user table or customize registration page in joomla it will restore to default once you upgrade your Joomla version.
The way to do this is:
You have to create another table which contains the other extra information and should with userid from #__users.
When submitting the form you have get the another table by using this Joomla code.
$module_table = JTable::getInstance('modules', 'profileTable');
Modules -> means table name which you created.
ProfileTable -> means "component name" is Model name and "Table" is common.
Then you have to pass the post values to this table like this..
if (!$module_table->bind($post))
{
return 0;
}
if (!$module_table->check())
{
return 0;
}
if (!$module_table->store())
{
return 0;
}
This way, you can store additional data for users. For displaying purposes, you will need to join the two tables by using userid and display it...
All the best..
We are new to Expression Engine and could maybe use some help from anyone who has built a few sites using this CMS.
We have a small dashboard system where users log in and read articles that are submitted from other authors. We are wanting to have a form which allows a member to chose which categories of articles he would like to be on his home page when he logs in. Then we'd like to figure out how to actually create that home page so that only the categories of articles that the user has chosen are visible.
From a DB standpoint this seems to be a one to many relationship between a member and categories, but we don't have a clear idea how to accomplish this inside of EE (without raw PHP/queries), especially using the Member module, since it isn't a channel and doesn't seem to allow creating relationships in the member custom fields.
We looked at creating a custom field for every category type, but there are about 95, and as we add or remove them, it would be extremely cumbersome to try to keep up with them all. Even if we did we still aren't sure how to connect 1 member to many categories or many entries via a category.
We'll update the question later to add some of the code we (if any) that we've come up with
In short, there isn't going to be a built in way to handle this. That isn't to say however that this can't be handled with some modules that are already out there. Let me ask you this. When you have users logging in, are they logging in to Expression Engine itself's backend, or the login system that you have created on a public facing website.
I am using Symfony 1.2.9 (with Propel ORM) to create a website. I have started using the admin generator to implement the admin functionality.
I have come accross a slight 'problem' however. My models are related (e.g. one table may have several 1:N relations and N:N relations). I have not found a way to address this satisfactorily yet. As a tactical solution (for list views), I have decided to simply show the parent object, and then add interactions to show the related objects.
I'll use a Blog model to illustrate this.
Here are the relationships for a blog model:
N:M relationship with Blogroll (models a blog roll)
1:N relationship with Blogpost (models a post submitted to a blog)
I had originally intended on displaying the (paged) blogpost list for a blog,, when it was selected, using AJAX, but I am struggling enough with the admin generator as it is, so I have shelved that idea - unless someone is kind enough to shed some light on how to do this.
Instead, what I am now doing (as a tactical/interim soln), is I have added interactions to the list view which allow a user to:
View a list of the blog roll for the
blog on that row
View a list of the posts for the blog on that row
Add a post for the blog on tha row
In all of the above, I have written actions that will basically forward the request to the approriate action (admin generated). However, I need to pass some parameters (like the blog id etc), so that the correct blog roll or blog post list etc is returned.
I am sure there is a better way of doing what I want to do, but in case there isn't here are my questions:
How may I obtain the object that relates to a specific row (of the
clicked link) in the list view (e.g. the blog object in this example)
Once I have the object, I may choose to extract various fields: id etc.
How can I pass these arguments to the admin generated action ?
Regarding the second question, my guess is that this may be the way to do it (I may be wrong)
public function executeMyAddedBlogRollInteractionLink(sfWebRequest $request)
{
// get the object *somehow* (I'm guessing this may work)
$object = $this->getRoute()->getObject();
// retrieve the required parameters from the object, and build a query string
$query_str=$object->getId();
//forward the request to the generated code (action to display blogroll list in this case)
$this->forward('backendmodulename',"getblogrolllistaction?params=$query_string");
}
This feels like a bit of a hack, but I'm not sure how else to go about it. I'm also not to keen on sending params (which may include user_id etc via a GET, even a POST is not that much safer, since it is fairly sraightforward to see what requests a browser is making). if there is a better way than what I suggest above to implement this kind of administration that is required for objects with 1 or more M:N relationships, I will be very glad to hear the "recommended" way of going about it.
I remember reading about marking certain actions as internal. i.e. callable from only within the app. I wonder if that would be useful in this instance?
I'm assuming your application is called backend. Suppose there are two models, BlogPost and BlogPostComment. These are managed using admin generated modules called blog_post and blog_post_comment.
I believe you want a link against each BlogPost displayed on the list page at backend.php/blog_post. The links take you to backend.php/blog_post_comment, which should only show comments related to the relevant BlogPost.
Under apps/backend/blog_post/templates, create a file called _commentslink.php and put this in it:
View Comments
Then in apps/backend/blog_post/config/generator.yml, you need to include this partial in the fields for the list view:
....
param:
config:
list:
display: [ id, title, _commentslink ]
Note the _commentslink - the _ tells it to use a partial instead of looking for the field in the model. Your object is available in this partial as $<name of model> - $blog_post in this case.
Essentially, all this method does is links to the same action as the filter on the comments list normally goes to, passing the relevant condition to it to make it filter by blogpost_id.
If you've got CSRF protection enabled in the backend, you'll need to disable it, or this method won't work. This is set in apps/backend/config/settings.yml. There will be a setting in there called csrf_secret - it should be set to false to disable csrf.
You should try symfony 1.3/1.4 out if you need support for 1:N relationships in forms. 1.3 is in my experience a relatively hassle free upgrade from 1.2.x - 1.4 is the same, but with deprecated features removed.