/    Sign up×
Community /Pin to ProfileBookmark

Getting a theme through a DB ID

I am currently creating my own Content Management System and I still need the system to show the files in the style folder.

I know how it needs to get working but I seem to not get it working .. Heres how I want it to work:

  • * Database which contains ID’s // Names // Active or not

  • * CMS back-end which GET’s information FROM styles table and shows all styles. Then gives you the ability to activate the styles which are same names as the folders INSIDE the folder “styles”.
  • I hope you guys still understand it and are willing to help me out.
    Kind Regards,
    Ixecube

    to post a comment
    PHP

    2 Comments(s)

    Copy linkTweet thisAlerts:
    @NoEffinWayFeb 23.2012 — I understand what you are trying to do but I would suggest doing it slightly different.

    PHP:
    [code=php]<?php
    if(isset($_GET['install'])){
    if(file_exists('style'.$_GET['install']){
    //Lets see if it is installed already
    $name = $_GET['install'];
    $find = mysql_query("SELECT * FROM $db.$table WHERE name='$name'");
    if(mysql_num_rows($find)!=0){
    $response = 'Style already exists in database!';
    }else{
    //Make the active column have a default val of 0
    //And use binary values (1=yes/on;2=no/off)
    $add = mysql_query("INSERT INTO $db.$table (name) VALUES ('$name')");
    if(!$add){
    $response = 'Error installing style: '.mysql_error();
    }else{
    $response = 'Style installed successfully.';
    }
    }
    }
    }

    if(isset($_POST['status']) && isset($_POST['style'])){
    $status = $_POST['status'];
    $style = $_POST['style'];
    $update = mysql_query("UPDATE $db.$table SET active='$name'");
    if(!$update){
    $response = 'Error installing style: '.mysql_error();
    }else{
    if($status == '0'){
    $status = 'deactivated';
    }else{
    $status = 'activated';
    }
    $response = 'Style "'.$style.'" '.$status;
    }
    }

    $installed = mysql_query("SELECT * FROM $db.$table");
    $instyles = '<select name="installedstyles">';
    while($array = mysql_fetch_array($installed)){
    if($array['active'] == '0'){
    $color = 'color:#f00';
    }else{
    $color = 'color:#0f0';
    }
    $instyles .= '<option style="'.$color.'" value="'.$array['id'].'">'.$array['name'].'</option>';
    }
    $instyles .= '</select>';
    $allstyles = '<select name="allstyles">';
    while (false !== ($entry = readdir('style/'))) {
    if($entry != '.' && $entry != '..'){
    $allstyles .= '<option value="'.$entry.'">'.$entry.'</option>';
    }
    }
    $allstyles .= '</select>';

    ?>[/code]



    [CODE]<form id="install" action="?" method="get">Available styles for installation:&nbsp;<?=$allstyles;?>&nbsp;|&nbsp;<input type="submit" value="Install" /></form>
    <form id="activate" action="?" method="post">Activate/Deactivate:&nbsp;<?=$allstyles;?>&nbsp;|&nbsp;<input type="submit" value="Activate/Deactivate" /></form>
    [/CODE]
    Copy linkTweet thisAlerts:
    @IxecubeauthorFeb 28.2012 — Thank you for the reply. I tried it out and it already helped me a bunch!
    ×

    Success!

    Help @Ixecube spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.15,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...