I am developing a website, and I need to give 'admin' user CRUD(create/read/update/delete) functionality.
I am developing using php and CodeIgniter.
I have a view called gallery.php which display thumbnails, as grid.
each thumbnail have 2 buttons below(edit,delete) the thumbnail.
I want...
admin user - need to see those 2 buttons.
all rest wont see those 2 buttons.
I what to use the same view(not to duplicate it...) and just hide those buttons in case user is not admin.
What do I need to do? passing $is_admin to gallery.php seems to be a little ugly i guess.
Thx
when you login check its admin or not than store into session variable.
no need to create same page again & again ..
no need to pass variable into url..
just use session variable for checking its admin or not.
Related
I want to use an opencart database for another website, so users don't need to register their details again.
For example: I sell Clothes (unStitched) on opencart and I also give services for stitching them. Opencart doesn't have a module to do this, so I want to redirect users to another website and there I want to read the user details for further processing.
How can I read PHPSESSID cookie? How does opencart read firstname on edit profile forms?
<?php echo $firstname; ?>
Thanks in advance.
In order to work with the Session data in an Opencart view, you will need to add some code to the controller. First we need to add an item in the $data array that the controller uses to pass variables to the view:
Assuming you want to show this link in a product view, you will need to edit the product controller's index action.
Controller file: public_html\catalog\controller\product\product.php
Find this line:
if ($product_info) {
Add the text inside the brace:
$data['mysessionvariable'] = $this->session;
You can restrict the available data to the sessionID only using the code below:
$data['mysessionvariable'] = $this->session->getId();
Now the relevant PHP Session data is available to the view, you can simply reference the session variable in the view wherever your need to. e.g. echo $mysessionvariable['session_id']; or echo $mysessionvariable;
View file: public_html\catalog\view\theme\default\template\product\product.tpl
I'm planning a site and I was thinking would it be possible to show alternate content in the sidebar based on the behaviour of the visitor? Say the user has clicked on link X on page A and I want the alternate content in the sidebar to be shown on page B, if they clicked on the link. Also, if the visitor fills out a form, would it be possible to associate the tracking cookie information with the submitted form to see what pages the visitor viewed? Would this be easier to implement in a particular cms?
I would appreciate it if someone could at least point me into the right direction. Thanks in advance!
Yes anything is possible & no need for cookies (unless you want to keep a persistent track of the user)
Have a relationship column next to the content in your db, when creating the content assign this value much like a category or tag ect.
Then when user clicks on link A as the page loads store its relationship in the session, then when link B is clicked load content related to the previous set session value.
I built a custom component for Joomla 1.5. It' an FAQ component.
I'd like to let users add questions from the Front-End.
I have several fields that shouldn't be displayed for the user on the front end.
For ex. in the back-end admin has fields like Approved, Ordering and Published and the rest. I would like to let any user without signing in to add question front the front-end but these 3 fields shouldn't be displayed to the users on the front-end.
So, how to build the front-end user input?
Maybe someone has done that or know some good tutorial for this case?
In the view.html.php file of your component (eg. com_faq/views/view.html.php) you can define the mark up for your input field section. I build up a $html variable like:
$html .= '<input name="addQuestion" value="" type="Text"/>';
then add a reference to it:
$this->assignRef("addQuestion", $html);
so that in your view template (i.e. com_faq/views/tmpl/default.php) you can add it to your page like
echo $this->addQuestion;
When you click your submit button you can reroute back to the same view. So user a url like
index.php?option=com_faq&task=addQuestion&view=default
So before you mark up your page (so within the first few lines of your display function for example) you can grab the contents of your user's input on the front end
$question = JRequest::getVar('addRequest', null);
Once you have this you can either store it to your database or display it. Alternatively you can AJAX submit your form and process it in a controller function so the you don't have the refresh etc.
You will need to edit your router.php file to pick up the task and pass it to your controller i.e. set it as a task or a view.
There are loads of options for this but fundamentally there are 3 things you need:
Create your mark up in your view.html.php file and assign a reference to it
Include the reference in your template i.e. default.php
Submit your form to an address that your same component can process it i.e. index.php?option=com_faq&task=addQuestion&view=default
Hope this helps :)
Does anyone know how I can manipulate joomla to only allow one view per user to certain articles? I am looking to make the article gray out and not allow the user to click on it after it has been viewed for the first time. Any help would be much appreciated.
Thank you,
Dave
This is would probably have to be a plugin. This could only really be reliably done on a page that requires a user to be logged in and you can't just register new accounts. Also someone could just copy the text the first time and then your security is moot. Nevertheless, the plugin would have to track the page ID and the user ID and when the visit the page a row gets added to table. Then you could have a page template where you check that table and if the row exists for that page id and user you do whatever to the content otherwise display it as normal.
I'm not sure why you would want to do this, but it would take a plugin that does several things. First, your content would have to be available to registered users only. Cookies would work, but it would be really easy to clear your cookies to regain access to the content. Next, the plugin would need to record every visit to the page, the record would need to include the userID. Last, the plugin would need to look up the specific user that is trying to access an article and check to see if they have been to the page before.
However, all of that work would not prevent anyone from registering another account to access the content again. Or copying and pasting the content or saving the page locally. Why would you want to limit your users to a single page view?
The only correct way to do is create a plugin "content" that will check the database in the field "hits". If it is greater than X, you can redirect Joomla to block his access:
$mainframe->redirect('index.php', JText::_('AN ERROR HAS OCCURED'));
The advantage of this method is that you have the option to reset the counter in the administration of articles
As for the display of the results list, I advise you to use your html file of your template to make such audit and carried away those who are no longer available.
Ok heres the senarrio, i have 4 wordpress installs as follows
top level = mysite.com/ *main site;
1st level = mysite.com/site1 *1st site
2st level = mysite.com/site2 *2nd site
3st level = mysite.com/site3 *3rd site
The front page on the main site has login forms to each of the three sub sites.
each site has different users, settings, content etc...
ie:
form 1
username & pass submit / form action="mysite.com/site1/wp-login.php"
form 2
username & pass submit / form action="mysite.com/site2/wp-login.php"
form 3
username & pass submit / form action="mysite.com/site3/wp-login.php"
when trying to login to any site, it will take the username/pass, submit the form
but come back to the front page were it first loaded, and not directing the user to the
control panel /siteX/
is this something that can be done? or would this require some other way of thinking.
using links to the actual page instead of having the 3 login forms on the one page..?
thanks
You probably want Sidebar Login: http://blue-anvil.com/download/?did=28
If you use this, the user is not redirected to the backend.
I would also advice you to look at WPMU if you are having multiple sites.
Update
You would have to edit the plugin to include a dropdown list, where you could select which site to login to.
Make sure the URLs for each installation is set to the correct value under Settings->General