Hi,
This is a feature request, or an inquiry if this exists, please tell me which module already does this.
My previous post about the kind of site I plan to use drupal on is here => : http://drupal.org/node/198051
I thought the practical approach for it is via a module.
This is how I want the module to function:
- Given a (page) content, I'd like to edit the texts/words on it without going through the edit-body field (as I don't want the users to have means of editing the actual HTML form.)
- The content has some php on it, that's why giving users means to edit the actual body code is not an option.
- Simply put, I was thinking of a module that would retrieve the parts of the content's text I choose/declared to be editable.
Something like this:
----code 1------
<h1>
<? php echo $_edit[h1]['step 1 header']; ?>
</h1>
<p>
<?php echo $_edit[pl_text]['step 1 page desc']; ?>
</p>
-------------
OR like this:
-----code 2-----
<div id="canEdit_step1H1" >
<h1>Search for a Domain</h1>
<div id="canEdit_step1descTXT"><p> Enter a domain name to search.</p></div>
------------------
and so forth..
code 1: I want to be able to set the values of $_edit array, and through an admin-like page or whatever, the user can edit and save those values.
code 2: similarly, I want to be able to set values of the texts via their HTML id's (using Javascript).
Is there an existing module close to this? This is only theoretical and I haven't taken a step to begin writing such a module. If there's a better way of achieving my proposed functionalities please enlighten me...
Thanks..
Comments
As a first step I would consider CCK
You are correct that in general you do not want users editing content with PHP code in it. On the other hand, that is easy to avoid since you can theme the code indepently of the content so I doubt the PHP code needs to be part of the content.
Starting with Drupal 5 you can add custom content type from Drupal admin. If you add the Content Construct Kit (CCK) you can extend those content types with fields of various types. With theming you can layout the resulting information to your liking.
Yes, I've tried CCK but..
Thanks for the suggestion, I think I figured out what I need to do.
I plan to use blocks (in which the supposed content is also a block in a custom defined region 'inline') because of the 'Edit this Block' snippet I've read here. That was closest to the interface we have right now. As for the filters, I think I want to implement some kind of macro so I could just set the input format filter to full HTML. This macro (which I have no clear idea how to implement as of now) will look for stuff like:
And load the appropriate data for it.
By the way, how or where is the preferred way of writing PHP code for my own functions (i.e. validation and processing of user inputs, retrieval of data from DB?) currently I've added my own file in the /includes/ of drupal, called domain.inc, which I've added to common.inc by adding it to the "require_once" declarations by the function _drupal_bootstrap_full() so all the subdomains can use the code. Is this ok, or is it bad practice?
Or is it best to just have my custom php functions in the theme files instead?
Thanks.
Some pointers
First one adding code, the "proper" approach is to write a module for the thngs you are trying to do, though I suspect you are overthinking the problem a bit. For validation you would want to implement to nodeapi hook in a module.
It is reading the DB I wonder about. If you implement the content using CCK you have a new content type and using theming you can format that content how ever you want. But the statement about blocks is confusing and I am not sure where that fits in.
Thanks.. I might be thinking of too many things
Thanks for the insight. I've got over this problem, for now, and I didn't have to use CCK after all.
This is where I'm at now:
You were right, the module is indeed the best way to achieve my goals. I've started learning to code through drupal's API, and it really simplifies things.
I've created my own module, which does this:
- Create custom blocks (via module.install)
- Create page contents (same)
- An "about site" menu for the ones that will use the site.
* Added the "Edit blocks" snippet on my themes for convenient editing.
The site is a subdomain, and we own the admin account, while the user of the site will be defined as a user with a role "private label owner"
Then, these are the only privileges that role will possess:
- Select different themes
- Administer Blocks
- Site information.. perhaps, for the site name, slogan, mission, etc.. haven't analyzed this option
- Administer URL aliases
- Create/Edit own page/story content
- Of course, access content
While these are the things I DON'T want users to have access to:
- Edit/delete our pages
- Access admin. pages, site config, modules, menus.
- Use PHP code for content pages, even blocks. (Administer Filters)
We plan to use macros to totally eliminate the cases of needing to use PHP codes for blocks/content and just allow HTML.
I think these controls fit my purpose, as custom blocks are the editable texts that users can manage, while the functional content/codes will be embedded in the content pages I've created.. So with this, I deny the users the power to edit page contents w/c they didn't author, no control over input filters (HTML only for them), no admin rights except for the ones specified above.
Well, I guess I have to put my php codes in the module, as of now it still in /includes/domain.inc and is called by common.inc.
Again thanks for the replies.