Regionalizing content display to users with matching region in profile - php

The requirement is to display all public content and all content that has been restricted to the viewer's region.
Currently this is being accomplished by producing two views in blocks on a standard page. One view is set up to display all news articles that do not have a "N" in a "restrict to region" field. Another view is set up to display all news articles that have a "Y" in a "restrict to region" field AND uses php code in a contextual filter to add the condition that the "region" field in the news article matches the "region" field in the user profile. Stacking these views in the content field of a standard page results in a page that returns all news articles that are not restricted AND all news articles that are restricted to the user's region.
Undesirable complications of this strategy include separate pagination and the necessity of creating multiple views to extend the functionality to additional content types or to expand to cities or states.
Can you think of a way to apply the complex filter on a single view so as to avoid the need for presenting a separate unrestricted view followed by a view restricted to records who's region matches the viewer's region?
Or to apply the filter as a permission on fields?
Thanks n advance,

It's quite simple you're using the wrong tool for the job.
PHP is not your tool of choice for this, you should be using the SQL directly.
$q="SELECT *
FROM
articles
WHERE
limited_to_region=0
UNION
SELECT
a.*
FROM
articles a
INNER JOIN
regions r
ON
a.rid=r.id
AND
r.id='".$_SESSION["user"]["region"]."';";
(I don't know your datamodel, you could/should have a relation item in between etc. but this best practice is far from the norm so ...)
This way your filtering and all that is transparent to your front end anyway, faster, limitless AND does not waste time/bandwidth transferring unneeded information.

add another column at your table [articles, news] in database for tags (text-type)[few tags can be set, split them by comma], then create another table that contains tags, give id of those tags to your articles/news. you can filter this content by finding users location by IP-Address, or setting an cookie if you know somehow where user is coming from.

Hope you're using Location for profiles and articles.
It sounds like to do want to mix these two result sets into one item list.
Back in the day it would be Views Union
Believe Ovideiu is correct about Views OR being the most modern solution to this. Its says dev, but folks use it in production.
If you don't have to combine the two set you could use Views Exclude Previous to take care of your duplicate items.
Unfortunately, when I've done this in the past we've had to create our own custom (yet cached) output solutions because we could control the query. But you can still use drupal queries and node_loads to make use of templates, etc.

Related

How To Break Up Company Website Into Groups To Manage Their Content

I've been looking around and not finding any good answers. I work at a small company. They have a quick information website for internal users. It needs updating but here is the situation. I want each group to be able to manage their own page/s contents. For instance HR to manage their documents, another group to manage the phone directory,etc. I don't want them all to have to be trained or take training on any extensive software. It doesn't even have to have a lot of features probably. I've been looking at possibly Joomla as our group already knows PHP, Apache, etc. But haven't really got a good feel if I can break the content up and assign certain areas to certain groups inside of it so they only have access to change their own content only.
Right now all of it's on one page and grew out of hand before I got here to 2 page list of items without a collapsible menu. I do like that some areas all they have to do is drop files on a file share to update their items. I may keep part of that, just break it up into separate pages instead of showing each in one single frame in the middle as you click on the menu item. Since most of it is documents it's not all that bad.
Anyway looking for someone that's already been down this road and has a feeling for what I'm trying to do and how to go about it.
BTW prefer something open source if adding on any product to what we have.
Joomla since version 1.6 has fine grained access control that you can customise your self. Normally what I would do is create a user group for each of your groups. THen create a category tree for that group to make and manage their articles. Then for each of these categories give members of the group permission to create, edit, delete or whatever you want them to have.
THere is a lot of documentation out there on how to do this. (Some by me :)) Just search for Joomla ACL or Joomla Access Control.
If you have using joomla, you have the choice to edit your mysql database, there are two tables you need to edit, one is users, the other is usergroup_map. Each group should have a group ID and its own permission. After you create a page, just assign the permission to the page. If you have more than 6 groups, you might also need to edit usergroup table to add more group ID

MySQL Organisation Strategy for Multi-user with 100% customization

My question today is how should I organize my MySQL Table to get a 100% customized menu for my different users...
Let me explain: I will have a large menu tree (like windows) that will display Categories & Items for the user. I want the user to be able to delete, add or Modify anything like: Category name, Delete category, Add item, Change item name and Delete Item.
BUT: I want to offer my different clients a starting "Base" menu with common Items and Categories when they register, but when a user modifies the category (ex: change name or delete it), I don't want his changes to interfere with the other user's Menu..
So, how should I organize my DB to handle this: at this moment, I have 2 Tables: T_categories(with parent info to structure for the tree menu) & T_items (with category_id) but I realize that I don't really know how I will be handling my queries to enable "delete or rename" for Categories and Items... Should I make unlimited tables like this??
T_user1_categories & T_user1_items
T_user2_categories & T_user2_items
and so on, but if I have 1000 users it'll not be cool =/
At this time I can only(i think) create customized items with ex: privateview_id (user id)
Also, if I build something that, when I rename a category, it create a new category with a privateview_ID, all the items that were already in it will lose their position
I'm using PHP and MySQL
If you have an idea, i will be happy to hear it!!
Thank-you!
Raphael
A menu bar is a hierarchical thing. I suggest you "build" that things using a hierarchical meta data like XML.
You can store your users, categories and items in respective tables and also create a menus table to store the menus users created.
You ill still be able to do relations between users, menus, categories and items creating relational tables.
Also a user can just move a item from a category for another, not changing your usersXcategories or usersXitems relations but just changing the XML.
I cannot say more without knowing more details but your requirements.
Well, finally i've come to conclusion that the best way will be to create a table for every users... I've read that some people have MySql databases with over 1000+ tables without any problem and going the other way would be a lot of trouble. Also, I don't plan on having 1000+ users because that custom menu is part of a "paying" option. Thank-you for your answer jean

Drupal route based node content

I'm new to Drupal and have a basic question which I cannot find a good answer to. I am trying to dynamicly determine the contents of my website based on a selection made by the user and keep the selection displayed in the routing for SEO purposes.
It's a website for a Restaurant with multiple franchises.
What i'm trying to do is the following:
The user visits my website and gets a splash screen presented with the available franchises or a textbox to enter his postalcode
Upon selecting he enters the main website with the navigational structure adapted to the selected franchise. For example: domain.com/city/, domain.com/city/menu, domain.com/city/menu/dishes, domain.com/city/contact, ...
The contents of all nodes are based upon the city the user selected. Some franchises have extra nodes which should be displayed in the main navigation aswell.
What I have thought about so far is to try to accomplish this with taxonomy but I really have no idea where to start. Parts of the nodes will be the same for all franchises other parts will be different. Menu item prices will also be different.
This is the first website i'm building using Drupal so any advice is welcome.
Thanks!
It will be impossible to explain it all here but yes it is possible to select your content based on user input in Drupal. You will need to look into Views & Panels.
In Views you can use arguments to narrow to a specific taxonomy. With Panels , an argument can be retrieved fron the URL and passed to the Views in order to display the results.
There are a lot of resources available, Merlin of Chaos, the author of the Views & Panels modules has written a book about it. There are video tutorials online. Your best bet is to start with drupal.org.

Magento - Multi-domain & Filters

We're looking to build in a filter to our Magento site with drop down choices for the first two options, a selection box for price plus a colour chooser.
Firstly how easy is it to fetch the info for the first two dropdowns from the database so the first box is populated with the first category then the second box populated with the choices for that particular category? (and then change if someone changes the first selection)
Secondly how easy is it to set up a separate filter for each site so it only fetches info for the corresponding store and doesn't show products from other stores?
The filter will only have to show the products when you press a 'find' button so I guess it's a case of building up the search query?
Thoughts and ideas on this would be great, only been working with Magento for a month so still not sure of it's full capabilities.
Thanks
For the second part Magento already shows only products relevant to a given store. When you set up the stores (in System > Store Management) you have the option of giving it a unique "root category". Creating root categories is easy, in Catalog > Manage Categories.
The first part requires some programming work. From your previous questions it looks like you have a good understanding of Javascript so AJAX is not a problem. I don't know how familiar you might be with PHP, listing products will require you create a new module, with it's own controller, that forms a collection from the selected category. Collections make their own queries so you don't need to write a lick of SQL, and they have functions for exporting as JSON or XML so you don't need to write that either. For an experienced programmer it would take almost no time at all.

Can I use one single exposed filter to filter multiple block views on a different page?

I have four block views on a page (call it "info" page) that are filtered by proximity to give me four pieces of information relating to one particular filtered location.
I would like to be able to create an intro page with an exposed proximity filter that when executed would take me to the (info) page and simultaneously filter the four views with the proximity entered on the intro page.
How can I do this? I am new to php but learning .... willing to work at it!
Thanks
If you're using Views in Drupal 6, the answer is yes -- with some important caveats.
Unlike normal forms in Drupal, Views' exposed filter values come in as $_GET params raher than $_POST. That means that you can populate an exposed filter just by appending ?filter=value&filter2=value2 etc... to the current URL.
The kicker is that if multiple views on the same page are looking for the same filter keys in the URL, they will both use the incoming filter value. You'll need to configure each view's list of exposed filters to make sure that they all user the same list of filters, with the same list of 'keys' for the incoming values. If you want the filter form to only appear once, you may have to do some crafty juggling as well--Views will want it to appear on each view by default, but there's an option on each view to move its exposed filters to a block; doing that and NOT enabling the exposed filter block effectively hides the view's exposed filter widgets, while keeping the filtering active if it comes in via the URL.
To summarize: make sure all four views have the same list of exposed filters, and are using the same 'keys' for the filters. Hide the exposed filter widgets on all but one of the views. At that point, it should work.

Categories