Manageable structure in Eloquent - eloquent

I need to use a Photo in several different places and cannot quite figure out what would be the best approach.
So basically, there is a gallery page on the website that shows a bunch of Photos. There is also a portfolio page, where each project has many Photos. There is a blog section too, and each blog has many Photos.
The common thing with these photos is that they have an image_url and a caption.
Project and Blog are Eloquent models and Photo model is a polymorphic model.
Project and Blog have:
public function photos()
{
return $this->morphMany('App\Photo', 'imageable');
}
And the Photo model has:
public function imageable()
{
return $this->morphTo();
}
This bit works fine. But my problem is that I want to attach this Photo model to the gallery as well. I'm thinking the two options I have, are:
Create a Gallery model, which will have just one entry, as the gallery is just one page. And the model would have the same photos() method as above.
When loading up the gallery page, retrieve all the photos that have imageable_id and imageable_type set to null. (This would mean that the photos that do not belong to neither Project nor Blog).
But I think there's a different, better approach that I cannot see. Any suggestions?

I think both of the approaches you have are how most people would do it. You could make a new query scope for Photo to easily return the ones not attached a Project or Blog. This is what I would do.

Related

Image Gallery using meteor

I'm using meteor to make a web page. A large part of the web page is Galleries of images. Is there an easy way to keep information about the images and either the images themselves or links to the images in a mongoDB such that a gallery can be created on the fly to suit details entered by the site user?
I'm not sure about StackOverflow's policies on this question, but I'll tell you what you can do.
First you'll need a way to upload images. There's a package called lepozepo which will perform that for you.
After you have that, you'll take the urls that lepozeop generates for you and save this to a collection. There are a number of ways you can do this, if you know javascript you know at least two ways to accomplish this.
Once your collection is saving the urls for you, you just have a template that returns to you the image entries from the collection by using a meteor helper. It would look something like:
Template.gallery.helpers({
images: function(){
return imageCollection.find();
}
});
And in your template
{{#each images}}
<img src="{{url}}>
{{/each}}

Tags vs. categories for website content?

I am creating a site for electronics and programming projects and articles, and I'm trying to figure out whether to use categories, tags or both. I've been leaning towards just using tags, as it's done here on StackOverflow.
Seen from the perspective of the user, what provides the best user experience and makes the information easy and intuitive to find. I realize that this is much a question of personal preference, but I am interested in hearing opinions.
Here is what I ended up doing: I implemented both categories and tags; a post can only have one category but multiple tags.
The category is used as part of the URL, this puts a keyword in the URL which is good for SEO and it makes the URLs more structured. The categories are selected from a drop-down menu, and they are required. Categories are type specific, meaning articles will probably not have the same categories as projects or images.
articles/foobar // Show all articles with the category foobar
articles/1/foobar/article_slug // View a specific article
Tags can be added and attached to a posts simply by typing them with comma separation, they are used in the meta keywords field. I don't think that matters much to SEO, but they are available so why not. Multiple tags can be attached to a post, but at least one is required. Tags are not type specific but universal, meaning that all resources may share the same tags. So a search for a tag may return articles, projects and images.
tags // Show all tags, and number of resources that use them
tags/foobar // Show all resources with the tag foobar
articles/tagged/foobar // Show all articles with the tag foobar

Allowing the user to select a picture from a list of options in confluence survey macro

I would like to know how I can add pictures/image functionality to the confluence survey macro. I would like the user to select a picture from a list of pictures in response to a question. First I need to find out a way the wiki owner can upload pictures for the users to select one. Secondly allowing the user to select one picture. I am a beginner trying to learn confluence/wiki technology. It would be great if someone could help in this regard.
I don't have any experience with the survey macro. On the once occasion when I needed to have a survey-esque function on confluence I just used html and js.
On the subject of attaching images I do have experience though. If you go up to the Edit drop down you'll see a link to Attachments. There you can upload images which will be attached to that page.
You might want to look into whether the survey macro has the ability to work in conjunction with the image gallery macro.
Use pictures instead of words in the survey macro option list.
{survey:title=MyTitle|choices=!apple.png!,!orange.png!,!banana.png!|changeableVotes=true|showSummary=true|showTopSummary=true|showLast=true|visibleVoters=true}This is a survey{survey}
You can also have words and pictures.
{survey:title=MyTitle|choices=!apple.png! I like apples,!orange.png! I like oranges,!banana.png! I like bananas|changeableVotes=true|showSummary=true|showTopSummary=true|showLast=true|visibleVoters=true}This is a survey{survey}

Enhanced Table extension for TYPO3

I'm fairly new to TYPO3 and as far as I can see it's pretty poorly maintained as far as documentation goes. Some of the tutorials and documentation are almost a decade old and I was wondering if anyone here knows of any useful extensions that could enhance the standard content tables in the backend.
I have some tables that contain a bunch of links with images. A sort of categories gallery with thumbnails if you will.
The point being that at some point this gets passed on to a client who won't know what to do with HTML markup and i was wondering if anyone knew of 1) a good WYSIWYG table editor extension and 2) a categories gallery plugin with the option to add thumbnails to each category.
Cheers.
Look for some of the more recent plugins. I don't usually go back more than a year or two when searching for an extension.
I'm not exactly sure what you're looking to do, but did you know you can arrange the standard image elements in different ways, linking each image to a different page, kind of like what can be seen at: http://www.thedemo.ca/demonstrations/image-and-text-alignment.html
Simon

Create WebPages like IMDB

I will be building a site for music reviews. Say, i review a album of "Summer Hits 2011". It would contain about 10-15 artists. Now, i have portfolios of all these 10-15 artists. In the review, the artist names should be a hyperlink. Is there any way to automatically make the artist names as hyperlinks, instead of manually making it a hyperlink by linking to the artist's page. I know the question is little bit vague, but i tried my best in putting it the right way.
I though of using asp.net. What do you guys suggest ? I have heard of CMS solutions like Drupal. If you can point me in the right direction it would be great.
A silly question - Where and how the information is stored. Pick a movie page in IMDB. Do they create a html page for this movie and keep it on the server. Or do they just query from DB and present it in template ?
Thanks,
Dev.