I have an article website. So far, all my articles have been created by me working with the code. Copying and pasting the code and editing the P tags, H1 tags, etc. This turns out to be a hassle and increases the chance of you making an error. Especially when the article has multiple pages.
Future-wise, I want users to create articles. So this is what I want: User clicks on button that says 'create an article' and then the user gets redirected to the article builder page where they can make an article for themselves. The user will create a name for their article, this name will create a folder on my server...for example: www.example.com/articles/name-of-article. Then the user can write the article. The user will abide by classes I have created for tags, but those tags will not be seen by the user. The user only sees that their content is getting adjusted well based on my CSS template. Also, if the user wants to add another page to the article, they can put in already built buttons...they just have to change the links to those buttons. The user should also have the ability to bold, underline, and italicize text.
Note: Users are working with a pre-built template, not a blank page. The template article includes a recommended panel, showing other articles. The user does not have permission to edit this panel.
I've heard about WYSIWYG HTML editors, but I just want to know if this is the right thing for what I want. Is there something else that can accomplish my task better? If WYSIWYG is the best answer, can it do everything I've asked for?
P.S: My article pages are PHP pages, with HTML and Javascript included.
You don't need to write html codes of articels in php. I would suggest you to use a content management system (CMS) like Wordpress.
What you want is a CMS. Wordpress is the best approach for your needs, but if you can't use it, you can search for other CMS systems/frameworks.
If you want to make/use your own, just remember to do a Template framework.
And appart of your main question about WYSIWYG, yes, you can do all you asked if it can be done with PHP.
Related
first post here.
I am making a site for someone who wants to embed their own youtube links. I am relatively new to web development and this is my first commission so I was wondering how I could hand over the site to the client and allow them to upload their links without me having to edit the mark up for him.
I understand how to use an '<iframe' youtube link in HTML to embed videos and am considering creating a database using PHPmyadmin that uses a form that the client can fill in with the iframe link whenever he needs to embed a new video.
I understand if that sounds like a convoluted way of doing this but if anyone knows a more intuitive way to solve this issue please let me know :)
I think it can be done using a database, may be MySQL, to keep it simple and a simple backend programming language, PHP would do.
You create an admin page just to collect the URLs from the admin. A nice little login page which stores admin username and password in a table. And you can use this module to assign roles to admin, add an admin or delete one.
Inside the module created above, create a page with a form to fetch and store URLs in the database. If you are going to categorize the videos, use suitable columns. Say you are going to categorize based on the genre and length, the table in your database should contain genre and length so that you can use them as filters later on.
Use cookies to create session for the admin. This is to avoid redirecting him to the login page after every single reload.
For all other user who is not admin, do not redirect to the admin page. Redirect them to a common page where they can search and enjoy the videos that the admin has added.
Again, like mentioned in many comments above, wordpress does it all. You have an option to use it too, it's free.
I want the user's profile to show everything (logged in navbar, textbox they use to post their content on and all of their content) and then show their profile with a logged out navbar, selected content the user wants to show and no textbox to post content.
I am breaking up the html files (e.g. header, footer and main content) into separate php files. Is that a good idea if I want to implement the above said ?
I'm still developing on localhost but here's the current file structure which is a bit messy. I'm also trying to implement MVC but due to my lack of knowledge so far, it hasn't been done.
However you seem fit, but nice practice could be dividing up backend / frontend. Or have a public and a private directory as top layer, then go from there.
And yes, breaking up your files in header.php, *content.php and footer.php is smart for what you want. By doing this, you allow yourself to edit the main parts of you page independently, without having to update many html or php files. Just one file will do for every page.
Also google stuff like "common practice" for php structures.
Account for REST in your workflow How to create a RESTfull api
This Stackoverflow on html/php inlining is also usefull maybe.
Page creating in PHP: I'm trying to learn how to make a cms but I couldn't understand something. For example in Wordpress when you click "create a new page" button what is happening at the backside? For example now I don't have any page.
I want to create these pages dynamically:
Home
About
Contact
After I want to add this pages in my menu. What is the best way to do that?
Questions:
Should I create a new php file to do this or just get data from my database which belongs to each page?
How I add these pages in my menu dynamically ?
What is htaccess? I couldn't understand that exactly it does relating the the processes of the files.
There are tutorials on internet but they always show how to get articles from database. When I have another item (for example a slider) I need a real page.
Can somebody suggest me a simple tutorial, or provide a clear explanation which explains the logic simply.
I have created something similar. This is how I did it (may not be the best way but it is certainly the easiest).
Create a template file and insert tags (!Title!, [[Title]], etc) where you want the new pages data to be inserted.
When creating a new page, read the contents of the template and replace the tags with the data submitted (I used titles, desc, h1, etc but this can also be achieved through a simple content function)
The user selects/creates the directory using mkdir()
All this is then stored in DB ready for the user to navigate to.
You can then use the DB entries to build a navigation menu
I have a website written in PHP (all of my functionality is complete) and I am now starting to add the interface. The site allows users to decide which language they want the pages displayed in. The information is stored in a cookie and then a language file is read when needed to display the correct content.
My question is, in terms of design, how could I allow the user to change the language? For example, using a dropdown box or some other method. I am looking for something that looks really good but is also really simple.
Dropdown in a modal confirmation window with overlay effect would be cool.
I've done a lot of small projects on the side lately where the client wants a good chunk of the website to stay the same, they just want to be able to edit particular "areas" of the site. Namely, some text in some box somewhere.
I've found that WordPress works for this pretty well. The interface is nice and friendly to use, and it's got lots of work behind it so I don't have to reinvent wheels, fix bugs, etc.
So what I wind up doing is making PHP pages which look like what the client wants, then making the content editable areas contain a particular post or page, which is what is editable in WordPress.
I'm having the particular page's contents displayed on the page using code like this
<?php echo apply_filters('the_content', $page_Contact->post_content); ?>
where $page_Contact is a variable defined elsewhere.
However, the "Preview" or "View Page"/"View Post" function on each page/post goes to the logical WordPress location and this is not the effect I want in this case.
So for example I have pages like this
www.site.com/index.php
www.site.com/about.php
www.site.com/contact.php
And so forth.
WordPress wants to have the "View Page" and "Preview Changes" links go places like
www.site.com/?page_id=2
www.site.com/?page_id=8&preview=true&preview_id=8&preview_nonce=45522671f5
Which is a problem because, in the permalink structure above, both of those go to the index.php page which, except for the page I'm using to structure index.php, it's not where I want the user/editor to go. And none of the cases above allow any sort of preview (which is a concession I'm willing to make given how I'm doing this)
Is there a way, preferably using a plugin to rig WordPress such that the preview for a page in the dashboard goes to a preview of the non-index.php page where the content will be housed? So for example the link for the "Contact" page in WordPress's dashboard goes to contact.php instead of ?page_id=2? This is a deal where I'm trying to get this done in the editing interface and I'm not concerned about the links in the site itself.
Obviously I would need to maintain this per-page and this would be a situation where new pages don't go up unless I put them there.
Take a look at the preview_post_link hook in WordPress -- it should be called when generating that link, and you can use that in conjunction with a custom field (or some logic) in order to construct whatever preview link you like.
Have you considered page links to plugin for wordpress? Also changing permalinks?